当前位置: 首页>>代码示例>>C++>>正文


C++ release_region函数代码示例

本文整理汇总了C++中release_region函数的典型用法代码示例。如果您正苦于以下问题:C++ release_region函数的具体用法?C++ release_region怎么用?C++ release_region使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了release_region函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: short_cleanup

void short_cleanup(void)
{
	short_base = 0x70;
	unregister_chrdev(major, "short");
	release_region(short_base, 2);
}
开发者ID:Jacob-jiangbo,项目名称:my-test,代码行数:6,代码来源:cmos.c

示例2: sb1000_probe_one

static int
sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id)
{
	struct net_device *dev;
	unsigned short ioaddr[2], irq;
	unsigned int serial_number;
	int error = -ENODEV;
	
	if (pnp_device_attach(pdev) < 0)
		return -ENODEV;
	if (pnp_activate_dev(pdev) < 0)
		goto out_detach;

	if (!pnp_port_valid(pdev, 0) || !pnp_port_valid(pdev, 1))
		goto out_disable;
	if (!pnp_irq_valid(pdev, 0))
		goto out_disable;
		
	serial_number = pdev->card->serial;
		
	ioaddr[0] = pnp_port_start(pdev, 0);
	ioaddr[1] = pnp_port_start(pdev, 0);
		
	irq = pnp_irq(pdev, 0);

	if (!request_region(ioaddr[0], 16, "sb1000"))
		goto out_disable;
	if (!request_region(ioaddr[1], 16, "sb1000"))
		goto out_release_region0;

	dev = alloc_etherdev(sizeof(struct sb1000_private));
	if (!dev) {
		error = -ENOMEM;
		goto out_release_regions;
	}

		 
	dev->base_addr = ioaddr[0];
	/* mem_start holds the second I/O address */
	dev->mem_start = ioaddr[1];
	dev->irq = irq;

	if (sb1000_debug > 0)
		printk(KERN_NOTICE "%s: sb1000 at (%#3.3lx,%#3.3lx), "
			"S/N %#8.8x, IRQ %d.\n", dev->name, dev->base_addr,
			dev->mem_start, serial_number, dev->irq);

	/*
	 * The SB1000 is an rx-only cable modem device.  The uplink is a modem
	 * and we do not want to arp on it.
	 */
	dev->flags = IFF_POINTOPOINT|IFF_NOARP;

	SET_MODULE_OWNER(dev);
	SET_NETDEV_DEV(dev, &pdev->dev);

	if (sb1000_debug > 0)
		printk(KERN_NOTICE "%s", version);

	/* The SB1000-specific entries in the device structure. */
	dev->open		= sb1000_open;
	dev->do_ioctl		= sb1000_dev_ioctl;
	dev->hard_start_xmit	= sb1000_start_xmit;
	dev->stop		= sb1000_close;
	dev->get_stats		= sb1000_stats;

	/* hardware address is 0:0:serial_number */
	dev->dev_addr[2]	= serial_number >> 24 & 0xff;
	dev->dev_addr[3]	= serial_number >> 16 & 0xff;
	dev->dev_addr[4]	= serial_number >>  8 & 0xff;
	dev->dev_addr[5]	= serial_number >>  0 & 0xff;

	pnp_set_drvdata(pdev, dev);

	error = register_netdev(dev);
	if (error)
		goto out_free_netdev;
	return 0;

 out_free_netdev:
	free_netdev(dev);
 out_release_regions:
	release_region(ioaddr[1], 16);
 out_release_region0:
	release_region(ioaddr[0], 16);
 out_disable:
	pnp_disable_dev(pdev);
 out_detach:
	pnp_device_detach(pdev);
	return error;
}
开发者ID:xricson,项目名称:knoppix,代码行数:91,代码来源:sb1000.c

示例3: ali1535_setup

/* Detect whether a ALI1535 can be found, and initialize it, where necessary.
   Note the differences between kernels with the old PCI BIOS interface and
   newer kernels with the real PCI interface. In compat.h some things are
   defined to make the transition easier. */
static int ali1535_setup(struct pci_dev *dev)
{
	int retval = -ENODEV;
	unsigned char temp;

	/* Check the following things:
		- SMB I/O address is initialized
		- Device is enabled
		- We can use the addresses
	*/

	/* Determine the address of the SMBus area */
	pci_read_config_word(dev, SMBBA, &ali1535_smba);
	ali1535_smba &= (0xffff & ~(ALI1535_SMB_IOSIZE - 1));
	if (ali1535_smba == 0) {
		dev_warn(&dev->dev,
			"ALI1535_smb region uninitialized - upgrade BIOS?\n");
		goto exit;
	}

	retval = acpi_check_region(ali1535_smba, ALI1535_SMB_IOSIZE,
				   ali1535_driver.name);
	if (retval)
		goto exit;

	if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE,
			    ali1535_driver.name)) {
		dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n",
			ali1535_smba);
		goto exit;
	}

	/* check if whole device is enabled */
	pci_read_config_byte(dev, SMBCFG, &temp);
	if ((temp & ALI1535_SMBIO_EN) == 0) {
		dev_err(&dev->dev, "SMB device not enabled - upgrade BIOS?\n");
		goto exit_free;
	}

	/* Is SMB Host controller enabled? */
	pci_read_config_byte(dev, SMBHSTCFG, &temp);
	if ((temp & 1) == 0) {
		dev_err(&dev->dev, "SMBus controller not enabled - upgrade BIOS?\n");
		goto exit_free;
	}

	/* set SMB clock to 74KHz as recommended in data sheet */
	pci_write_config_byte(dev, SMBCLK, 0x20);

	/*
	  The interrupt routing for SMB is set up in register 0x77 in the
	  1533 ISA Bridge device, NOT in the 7101 device.
	  Don't bother with finding the 1533 device and reading the register.
	if ((....... & 0x0F) == 1)
		dev_dbg(&dev->dev, "ALI1535 using Interrupt 9 for SMBus.\n");
	*/
	pci_read_config_byte(dev, SMBREV, &temp);
	dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp);
	dev_dbg(&dev->dev, "ALI1535_smba = 0x%X\n", ali1535_smba);

	retval = 0;
exit:
	return retval;

exit_free:
	release_region(ali1535_smba, ALI1535_SMB_IOSIZE);
	return retval;
}
开发者ID:458941968,项目名称:mini2440-kernel-2.6.29,代码行数:72,代码来源:i2c-ali1535.c

示例4: bit_velle_exit

static void __exit bit_velle_exit(void)
{
    release_region( base , (base == 0x3bc)? 3 : 8 );
}
开发者ID:hugh712,项目名称:Jollen,代码行数:4,代码来源:i2c-velleman.c

示例5: check_arcofi

static int
check_arcofi(struct IsdnCardState *cs)
{
    int arcofi_present = 0;
    char tmp[40];
    char *t;
    u_char *p;

    if (!cs->dc.isac.mon_tx)
        if (!(cs->dc.isac.mon_tx=kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) {
            if (cs->debug & L1_DEB_WARN)
                debugl1(cs, "ISAC MON TX out of buffers!");
            return(0);
        }
    cs->dc.isac.arcofi_bc = 0;
    arcofi_fsm(cs, ARCOFI_START, &ARCOFI_VERSION);
    interruptible_sleep_on(&cs->dc.isac.arcofi_wait);
    if (!test_and_clear_bit(FLG_ARCOFI_ERROR, &cs->HW_Flags)) {
            debugl1(cs, "Arcofi response received %d bytes", cs->dc.isac.mon_rxp);
            p = cs->dc.isac.mon_rx;
            t = tmp;
            t += sprintf(tmp, "Arcofi data");
            QuickHex(t, p, cs->dc.isac.mon_rxp);
            debugl1(cs, tmp);
            if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
                switch(cs->dc.isac.mon_rx[1]) {
                    case 0x80:
                        debugl1(cs, "Arcofi 2160 detected");
                        arcofi_present = 1;
                        break;
                    case 0x82:
                        debugl1(cs, "Arcofi 2165 detected");
                        arcofi_present = 2;
                        break;
                    case 0x84:
                        debugl1(cs, "Arcofi 2163 detected");
                        arcofi_present = 3;
                        break;
                    default:
                        debugl1(cs, "unknown Arcofi response");
                        break;
                }
            } else
                debugl1(cs, "undefined Monitor response");
            cs->dc.isac.mon_rxp = 0;
    } else if (cs->dc.isac.mon_tx) {
        debugl1(cs, "Arcofi not detected");
    }
    if (arcofi_present) {
        if (cs->subtyp==ELSA_QS1000) {
            cs->subtyp = ELSA_QS3000;
            printk(KERN_INFO
                "Elsa: %s detected modem at 0x%lx\n",
                Elsa_Types[cs->subtyp],
                cs->hw.elsa.base+8);
            release_region(cs->hw.elsa.base, 8);
            if (!request_region(cs->hw.elsa.base, 16, "elsa isdn modem")) {
                printk(KERN_WARNING
                    "HiSax: %s config port %lx-%lx already in use\n",
                    Elsa_Types[cs->subtyp],
                    cs->hw.elsa.base + 8,
                    cs->hw.elsa.base + 16);
            }
        } else if (cs->subtyp==ELSA_PCC16) {
            cs->subtyp = ELSA_PCF;
            printk(KERN_INFO
                "Elsa: %s detected modem at 0x%lx\n",
                Elsa_Types[cs->subtyp],
                cs->hw.elsa.base+8);
            release_region(cs->hw.elsa.base, 8);
            if (!request_region(cs->hw.elsa.base, 16, "elsa isdn modem")) {
                printk(KERN_WARNING
                    "HiSax: %s config port %lx-%lx already in use\n",
                    Elsa_Types[cs->subtyp],
                    cs->hw.elsa.base + 8,
                    cs->hw.elsa.base + 16);
            }
        } else
            printk(KERN_INFO
                "Elsa: %s detected modem at 0x%lx\n",
                Elsa_Types[cs->subtyp],
                cs->hw.elsa.base+8);
        arcofi_fsm(cs, ARCOFI_START, &ARCOFI_XOP_0);
        interruptible_sleep_on(&cs->dc.isac.arcofi_wait);
        return(1);
    }
    return(0);
}
开发者ID:274914765,项目名称:C,代码行数:88,代码来源:elsa.c

示例6: com20020pci_probe

static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
	struct net_device *dev;
	struct arcnet_local *lp;
	int ioaddr, err;

	if (pci_enable_device(pdev))
		return -EIO;
	dev = alloc_arcdev(device);
	if (!dev)
		return -ENOMEM;
	lp = netdev_priv(dev);

	pci_set_drvdata(pdev, dev);

	// SOHARD needs PCI base addr 4
	if (pdev->vendor==0x10B5) {
		BUGMSG(D_NORMAL, "SOHARD\n");
		ioaddr = pci_resource_start(pdev, 4);
	}
	else {
		BUGMSG(D_NORMAL, "Contemporary Controls\n");
		ioaddr = pci_resource_start(pdev, 2);
	}

	if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com20020-pci")) {
		BUGMSG(D_INIT, "IO region %xh-%xh already allocated.\n",
		       ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
		err = -EBUSY;
		goto out_dev;
	}

	// Dummy access after Reset
	// ARCNET controller needs this access to detect bustype
	outb(0x00,ioaddr+1);
	inb(ioaddr+1);

	dev->base_addr = ioaddr;
	dev->irq = pdev->irq;
	dev->dev_addr[0] = node;
	lp->card_name = "PCI COM20020";
	lp->card_flags = id->driver_data;
	lp->backplane = backplane;
	lp->clockp = clockp & 7;
	lp->clockm = clockm & 3;
	lp->timeout = timeout;
	lp->hw.owner = THIS_MODULE;

	if (ASTATUS() == 0xFF) {
		BUGMSG(D_NORMAL, "IO address %Xh was reported by PCI BIOS, "
		       "but seems empty!\n", ioaddr);
		err = -EIO;
		goto out_port;
	}
	if (com20020_check(dev)) {
		err = -EIO;
		goto out_port;
	}

	if ((err = com20020_found(dev, IRQF_SHARED)) != 0)
	        goto out_port;

	return 0;

out_port:
	release_region(ioaddr, ARCNET_TOTAL_SIZE);
out_dev:
	free_netdev(dev);
	return err;
}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:70,代码来源:com20020-pci.c

示例7: snd_sc6000_probe


//.........这里部分代码省略.........
		snd_printk(KERN_ERR PFX
			   "I/O port cannot be iomaped.\n");
		err = -EBUSY;
		goto err_unmap1;
	}

	/* to make it marked as used */
	if (!request_region(mss_port[dev], 4, DRV_NAME)) {
		snd_printk(KERN_ERR PFX
			   "SC-6000 port I/O port region is already in use.\n");
		err = -EBUSY;
		goto err_unmap1;
	}
	vmss_port = devm_ioport_map(devptr, mss_port[dev], 4);
	if (!vport) {
		snd_printk(KERN_ERR PFX
			   "MSS port I/O cannot be iomaped.\n");
		err = -EBUSY;
		goto err_unmap2;
	}

	snd_printd("Initializing BASE[0x%lx] IRQ[%d] DMA[%d] MIRQ[%d]\n",
		   port[dev], xirq, xdma,
		   mpu_irq[dev] == SNDRV_AUTO_IRQ ? 0 : mpu_irq[dev]);

	err = sc6000_init_board(vport, xirq, xdma, vmss_port, mpu_irq[dev]);
	if (err < 0)
		goto err_unmap2;

	err = snd_wss_create(card, mss_port[dev] + 4,  -1, xirq, xdma, -1,
			     WSS_HW_DETECT, 0, &chip);
	if (err < 0)
		goto err_unmap2;
	card->private_data = chip;

	err = snd_wss_pcm(chip, 0, NULL);
	if (err < 0) {
		snd_printk(KERN_ERR PFX
			   "error creating new WSS PCM device\n");
		goto err_unmap2;
	}
	err = snd_wss_mixer(chip);
	if (err < 0) {
		snd_printk(KERN_ERR PFX "error creating new WSS mixer\n");
		goto err_unmap2;
	}
	err = snd_sc6000_mixer(chip);
	if (err < 0) {
		snd_printk(KERN_ERR PFX "the mixer rewrite failed\n");
		goto err_unmap2;
	}
	if (snd_opl3_create(card,
			    0x388, 0x388 + 2,
			    OPL3_HW_AUTO, 0, &opl3) < 0) {
		snd_printk(KERN_ERR PFX "no OPL device at 0x%x-0x%x ?\n",
			   0x388, 0x388 + 2);
	} else {
		err = snd_opl3_timer_new(opl3, 0, 1);
		if (err < 0)
			goto err_unmap2;

		err = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
		if (err < 0)
			goto err_unmap2;
	}

	if (mpu_port[dev] != SNDRV_AUTO_PORT) {
		if (mpu_irq[dev] == SNDRV_AUTO_IRQ)
			mpu_irq[dev] = -1;
		if (snd_mpu401_uart_new(card, 0,
					MPU401_HW_MPU401,
					mpu_port[dev], 0,
					mpu_irq[dev], IRQF_DISABLED,
					NULL) < 0)
			snd_printk(KERN_ERR "no MPU-401 device at 0x%lx ?\n",
					mpu_port[dev]);
	}

	strcpy(card->driver, DRV_NAME);
	strcpy(card->shortname, "SC-6000");
	sprintf(card->longname, "Gallant SC-6000 at 0x%lx, irq %d, dma %d",
		mss_port[dev], xirq, xdma);

	snd_card_set_dev(card, devptr);

	err = snd_card_register(card);
	if (err < 0)
		goto err_unmap2;

	dev_set_drvdata(devptr, card);
	return 0;

err_unmap2:
	release_region(mss_port[dev], 4);
err_unmap1:
	release_region(port[dev], 0x10);
err_exit:
	snd_card_free(card);
	return err;
}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:101,代码来源:sc6000.c

示例8: com90xx_probe

static void __init com90xx_probe(void)
{
	int count, status, ioaddr, numprint, airq, openparen = 0;
	unsigned long airqmask;
	int ports[(0x3f0 - 0x200) / 16 + 1] =
	{0};
	unsigned long *shmems;
	void __iomem **iomem;
	int numports, numshmems, *port;
	u_long *p;
	int index;

	if (!io && !irq && !shmem && !*device && com90xx_skip_probe)
		return;

	shmems = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(unsigned long),
			 GFP_KERNEL);
	if (!shmems)
		return;
	iomem = kzalloc(((0x100000-0xa0000) / 0x800) * sizeof(void __iomem *),
			 GFP_KERNEL);
	if (!iomem) {
		kfree(shmems);
		return;
	}

	BUGLVL(D_NORMAL) printk(VERSION);

	/* set up the arrays where we'll store the possible probe addresses */
	numports = numshmems = 0;
	if (io)
		ports[numports++] = io;
	else
		for (count = 0x200; count <= 0x3f0; count += 16)
			ports[numports++] = count;
	if (shmem)
		shmems[numshmems++] = shmem;
	else
		for (count = 0xA0000; count <= 0xFF800; count += 2048)
			shmems[numshmems++] = count;

	/* Stage 1: abandon any reserved ports, or ones with status==0xFF
	 * (empty), and reset any others by reading the reset port.
	 */
	numprint = -1;
	for (port = &ports[0]; port - ports < numports; port++) {
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S1: ");
		}
		BUGMSG2(D_INIT, "%Xh ", *port);

		ioaddr = *port;

		if (!request_region(*port, ARCNET_TOTAL_SIZE, "arcnet (90xx)")) {
			BUGMSG2(D_INIT_REASONS, "(request_region)\n");
			BUGMSG2(D_INIT_REASONS, "S1: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			*port-- = ports[--numports];
			continue;
		}
		if (ASTATUS() == 0xFF) {
			BUGMSG2(D_INIT_REASONS, "(empty)\n");
			BUGMSG2(D_INIT_REASONS, "S1: ");
			BUGLVL(D_INIT_REASONS) numprint = 0;
			release_region(*port, ARCNET_TOTAL_SIZE);
			*port-- = ports[--numports];
			continue;
		}
		inb(_RESET);	/* begin resetting card */

		BUGMSG2(D_INIT_REASONS, "\n");
		BUGMSG2(D_INIT_REASONS, "S1: ");
		BUGLVL(D_INIT_REASONS) numprint = 0;
	}
	BUGMSG2(D_INIT, "\n");

	if (!numports) {
		BUGMSG2(D_NORMAL, "S1: No ARCnet cards found.\n");
		kfree(shmems);
		kfree(iomem);
		return;
	}
	/* Stage 2: we have now reset any possible ARCnet cards, so we can't
	 * do anything until they finish.  If D_INIT, print the list of
	 * cards that are left.
	 */
	numprint = -1;
	for (port = &ports[0]; port < ports + numports; port++) {
		numprint++;
		numprint %= 8;
		if (!numprint) {
			BUGMSG2(D_INIT, "\n");
			BUGMSG2(D_INIT, "S2: ");
		}
		BUGMSG2(D_INIT, "%Xh ", *port);
	}
	BUGMSG2(D_INIT, "\n");
//.........这里部分代码省略.........
开发者ID:andi34,项目名称:Dhollmen_Kernel,代码行数:101,代码来源:com90xx.c

示例9: ac_probe1


//.........这里部分代码省略.........

	printk(KERN_DEBUG "AC3200 in EISA slot %d, node %pM",
	       ioaddr/0x1000, dev->dev_addr);
#if 0
	/* Check the vendor ID/prefix. Redundant after checking the EISA ID */
	if (inb(ioaddr + AC_SA_PROM + 0) != AC_ADDR0
		|| inb(ioaddr + AC_SA_PROM + 1) != AC_ADDR1
		|| inb(ioaddr + AC_SA_PROM + 2) != AC_ADDR2 ) {
		printk(", not found (invalid prefix).\n");
		retval = -ENODEV;
		goto out;
	}
#endif

	/* Assign and allocate the interrupt now. */
	if (dev->irq == 0) {
		dev->irq = config2irq(inb(ioaddr + AC_CONFIG));
		printk(", using");
	} else {
		dev->irq = irq_canonicalize(dev->irq);
		printk(", assigning");
	}

	retval = request_irq(dev->irq, ei_interrupt, 0, DRV_NAME, dev);
	if (retval) {
		printk (" nothing! Unable to get IRQ %d.\n", dev->irq);
		goto out;
	}

	printk(" IRQ %d, %s port\n", dev->irq, port_name[dev->if_port]);

	dev->base_addr = ioaddr;

#ifdef notyet
	if (dev->mem_start)	{		/* Override the value from the board. */
		for (i = 0; i < 7; i++)
			if (addrmap[i] == dev->mem_start)
				break;
		if (i >= 7)
			i = 0;
		outb((inb(ioaddr + AC_CONFIG) & ~7) | i, ioaddr + AC_CONFIG);
	}
#endif

	dev->if_port = inb(ioaddr + AC_CONFIG) >> 6;
	dev->mem_start = config2mem(inb(ioaddr + AC_CONFIG));

	printk("%s: AC3200 at %#3x with %dkB memory at physical address %#lx.\n",
			dev->name, ioaddr, AC_STOP_PG/4, dev->mem_start);

	/*
	 *  BEWARE!! Some dain-bramaged EISA SCUs will allow you to put
	 *  the card mem within the region covered by `normal' RAM  !!!
	 *
	 *  ioremap() will fail in that case.
	 */
	ei_status.mem = ioremap(dev->mem_start, AC_STOP_PG*0x100);
	if (!ei_status.mem) {
		printk(KERN_ERR "ac3200.c: Unable to remap card memory above 1MB !!\n");
		printk(KERN_ERR "ac3200.c: Try using EISA SCU to set memory below 1MB.\n");
		printk(KERN_ERR "ac3200.c: Driver NOT installed.\n");
		retval = -EINVAL;
		goto out1;
	}
	printk("ac3200.c: remapped %dkB card memory to virtual address %p\n",
			AC_STOP_PG/4, ei_status.mem);

	dev->mem_start = (unsigned long)ei_status.mem;
	dev->mem_end = dev->mem_start + (AC_STOP_PG - AC_START_PG)*256;

	ei_status.name = "AC3200";
	ei_status.tx_start_page = AC_START_PG;
	ei_status.rx_start_page = AC_START_PG + TX_PAGES;
	ei_status.stop_page = AC_STOP_PG;
	ei_status.word16 = 1;

	if (ei_debug > 0)
		printk(version);

	ei_status.reset_8390 = &ac_reset_8390;
	ei_status.block_input = &ac_block_input;
	ei_status.block_output = &ac_block_output;
	ei_status.get_8390_hdr = &ac_get_8390_hdr;

	dev->netdev_ops = &ac_netdev_ops;
	NS8390_init(dev, 0);

	retval = register_netdev(dev);
	if (retval)
		goto out2;
	return 0;
out2:
	if (ei_status.reg0)
		iounmap(ei_status.mem);
out1:
	free_irq(dev->irq, dev);
out:
	release_region(ioaddr, AC_IO_EXTENT);
	return retval;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:101,代码来源:ac3200.c

示例10: ibmlana_init_one


//.........这里部分代码省略.........
	dev = alloc_etherdev(sizeof(ibmlana_priv));
	if (!dev)
		return -ENOMEM;

	dev->irq = ibmlana_irq;
	dev->base_addr = ibmlana_io;

	base = dev->mem_start;
	irq = dev->irq;

	/* deduce card addresses */
	getaddrs(mdev, &base, &memlen, &iobase, &irq, &medium);

	/* were we looking for something different ? */
	if (dev->irq && dev->irq != irq) {
		rc = -ENODEV;
		goto err_out;
	}
	if (dev->mem_start && dev->mem_start != base) {
		rc = -ENODEV;
		goto err_out;
	}

	/* announce success */
	printk(KERN_INFO "%s: IBM LAN Adapter/A found in slot %d\n", dev->name, slot + 1);

	/* try to obtain I/O range */
	if (!request_region(iobase, IBM_LANA_IORANGE, DRV_NAME)) {
		printk(KERN_ERR "%s: cannot allocate I/O range at %#x!\n", DRV_NAME, iobase);
		startslot = slot + 1;
		rc = -EBUSY;
		goto err_out;
	}

	priv = netdev_priv(dev);
	priv->slot = slot;
	priv->realirq = mca_device_transform_irq(mdev, irq);
	priv->medium = medium;
	spin_lock_init(&priv->lock);

	/* set base + irq for this device (irq not allocated so far) */

	dev->irq = 0;
	dev->mem_start = base;
	dev->mem_end = base + memlen;
	dev->base_addr = iobase;

	priv->base = ioremap(base, memlen);
	if (!priv->base) {
		printk(KERN_ERR "%s: cannot remap memory!\n", DRV_NAME);
		startslot = slot + 1;
		rc = -EBUSY;
		goto err_out_reg;
	}

	mca_device_set_name(mdev, ibmlana_adapter_names[mdev->index]);
	mca_device_set_claim(mdev, 1);

	/* set methods */
	dev->netdev_ops = &ibmlana_netdev_ops;
	dev->flags |= IFF_MULTICAST;

	/* copy out MAC address */

	for (z = 0; z < sizeof(dev->dev_addr); z++)
		dev->dev_addr[z] = inb(dev->base_addr + MACADDRPROM + z);

	/* print config */

	printk(KERN_INFO "%s: IRQ %d, I/O %#lx, memory %#lx-%#lx, "
	       "MAC address %pM.\n",
	       dev->name, priv->realirq, dev->base_addr,
	       dev->mem_start, dev->mem_end - 1,
	       dev->dev_addr);
	printk(KERN_INFO "%s: %s medium\n", dev->name, MediaNames[priv->medium]);

	/* reset board */

	ResetBoard(dev);

	/* next probe will start at next slot */

	startslot = slot + 1;

	rc = register_netdev(dev);
	if (rc)
		goto err_out_claimed;

	dev_set_drvdata(kdev, dev);
	return 0;

err_out_claimed:
	mca_device_set_claim(mdev, 0);
	iounmap(priv->base);
err_out_reg:
	release_region(iobase, IBM_LANA_IORANGE);
err_out:
	free_netdev(dev);
	return rc;
}
开发者ID:ClarkChen633,项目名称:rtl819x-toolchain,代码行数:101,代码来源:ibmlana.c

示例11: setup_card


//.........这里部分代码省略.........
	tp->sifreadw = proteon_sifreadw;
	tp->sifwriteb = proteon_sifwriteb;
	tp->sifwritew = proteon_sifwritew;
	
	memcpy(tp->ProductID, cardname, PROD_ID_SIZE + 1);

	tp->tmspriv = NULL;

	dev->open = proteon_open;
	dev->stop = tms380tr_close;

	if (dev->irq == 0)
	{
		for(j = 0; irqlist[j] != 0; j++)
		{
			dev->irq = irqlist[j];
			if (!request_irq(dev->irq, tms380tr_interrupt, 0, 
				cardname, dev))
				break;
                }
		
                if(irqlist[j] == 0)
                {
                        printk(KERN_INFO "proteon.c: AutoSelect no IRQ available\n");
			goto out3;
		}
	}
	else
	{
		for(j = 0; irqlist[j] != 0; j++)
			if (irqlist[j] == dev->irq)
				break;
		if (irqlist[j] == 0)
		{
			printk(KERN_INFO "proteon.c: Illegal IRQ %d specified\n",
				dev->irq);
			goto out3;
		}
		if (request_irq(dev->irq, tms380tr_interrupt, 0, 
			cardname, dev))
		{
                        printk(KERN_INFO "proteon.c: Selected IRQ %d not available\n",
				dev->irq);
			goto out3;
		}
	}

	if (dev->dma == 0)
	{
		for(j = 0; dmalist[j] != 0; j++)
		{
			dev->dma = dmalist[j];
                        if (!request_dma(dev->dma, cardname))
				break;
		}

		if(dmalist[j] == 0)
		{
			printk(KERN_INFO "proteon.c: AutoSelect no DMA available\n");
			goto out2;
		}
	}
	else
	{
		for(j = 0; dmalist[j] != 0; j++)
			if (dmalist[j] == dev->dma)
				break;
		if (dmalist[j] == 0)
		{
                        printk(KERN_INFO "proteon.c: Illegal DMA %d specified\n",
				dev->dma);
			goto out2;
		}
		if (request_dma(dev->dma, cardname))
		{
                        printk(KERN_INFO "proteon.c: Selected DMA %d not available\n",
				dev->dma);
			goto out2;
		}
	}

	err = register_netdev(dev);
	if (err)
		goto out;

	printk(KERN_DEBUG "%s:    IO: %#4lx  IRQ: %d  DMA: %d\n",
	       dev->name, dev->base_addr, dev->irq, dev->dma);

	return 0;
out:
	free_dma(dev->dma);
out2:
	free_irq(dev->irq, dev);
out3:
	tmsdev_term(dev);
out4:
	release_region(dev->base_addr, PROTEON_IO_EXTENT);
out5:
	return err;
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:101,代码来源:proteon.c

示例12: dtlk_dev_probe


//.........这里部分代码省略.........
#if 0
		printk("DoubleTalk PC - Port %03x = %04x\n",
		       dtlk_portlist[i], (testval = inw_p(dtlk_portlist[i])));
#endif

		if (!request_region(dtlk_portlist[i], DTLK_IO_EXTENT, 
			       "dtlk"))
			continue;
		testval = inw_p(dtlk_portlist[i]);
		if ((testval &= 0xfbff) == 0x107f) {
			dtlk_port_lpc = dtlk_portlist[i];
			dtlk_port_tts = dtlk_port_lpc + 1;

			sp = dtlk_interrogate();
			printk("DoubleTalk PC at %03x-%03x, "
			       "ROM version %s, serial number %u",
			       dtlk_portlist[i], dtlk_portlist[i] +
			       DTLK_IO_EXTENT - 1,
			       sp->rom_version, sp->serial_number);

                        /* put LPC port into known state, so
			   dtlk_readable() gives valid result */
			outb_p(0xff, dtlk_port_lpc); 

                        /* INIT string and index marker */
			dtlk_write_bytes("\036\[email protected]\0\0012I\r", 8);
			/* posting an index takes 18 msec.  Here, we
			   wait up to 100 msec to see whether it
			   appears. */
			msleep_interruptible(100);
			dtlk_has_indexing = dtlk_readable();
#ifdef TRACING
			printk(", indexing %d\n", dtlk_has_indexing);
#endif
#ifdef INSCOPE
			{
/* This macro records ten samples read from the LPC port, for later display */
#define LOOK					\
for (i = 0; i < 10; i++)			\
  {						\
    buffer[b++] = inb_p(dtlk_port_lpc);		\
    __delay(loops_per_jiffy/(1000000/HZ));             \
  }
				char buffer[1000];
				int b = 0, i, j;

				LOOK
				outb_p(0xff, dtlk_port_lpc);
				buffer[b++] = 0;
				LOOK
				dtlk_write_bytes("\0012I\r", 4);
				buffer[b++] = 0;
				__delay(50 * loops_per_jiffy / (1000/HZ));
				outb_p(0xff, dtlk_port_lpc);
				buffer[b++] = 0;
				LOOK

				printk("\n");
				for (j = 0; j < b; j++)
					printk(" %02x", buffer[j]);
				printk("\n");
			}
#endif				/* INSCOPE */

#ifdef OUTSCOPE
			{
/* This macro records ten samples read from the TTS port, for later display */
#define LOOK					\
for (i = 0; i < 10; i++)			\
  {						\
    buffer[b++] = inb_p(dtlk_port_tts);		\
    __delay(loops_per_jiffy/(1000000/HZ));  /* 1 us */ \
  }
				char buffer[1000];
				int b = 0, i, j;

				mdelay(10);	/* 10 ms */
				LOOK
				outb_p(0x03, dtlk_port_tts);
				buffer[b++] = 0;
				LOOK
				LOOK

				printk("\n");
				for (j = 0; j < b; j++)
					printk(" %02x", buffer[j]);
				printk("\n");
			}
#endif				/* OUTSCOPE */

			dtlk_write_bytes("Double Talk found", 18);

			return 0;
		}
		release_region(dtlk_portlist[i], DTLK_IO_EXTENT);
	}

	printk(KERN_INFO "DoubleTalk PC - not found\n");
	return -ENODEV;
}
开发者ID:godknowspe,项目名称:linux,代码行数:101,代码来源:dtlk.c

示例13: sp5100_tco_ioctl


//.........这里部分代码省略.........
	val |= SP5100_PCI_WATCHDOG_DECODE_EN;

	pci_write_config_dword(sp5100_tco_pci,
			       SP5100_PCI_WATCHDOG_MISC_REG,
			       val);

	/* Enable Watchdog timer and set the resolution to 1 sec. */
	outb(SP5100_PM_WATCHDOG_CONTROL, SP5100_IO_PM_INDEX_REG);
	val = inb(SP5100_IO_PM_DATA_REG);
	val |= SP5100_PM_WATCHDOG_SECOND_RES;
	val &= ~SP5100_PM_WATCHDOG_DISABLE;
	outb(val, SP5100_IO_PM_DATA_REG);

	/* Check that the watchdog action is set to reset the system. */
	val = readl(SP5100_WDT_CONTROL(tcobase));
	val &= ~SP5100_PM_WATCHDOG_ACTION_RESET;
	writel(val, SP5100_WDT_CONTROL(tcobase));

	/* Set a reasonable heartbeat before we stop the timer */
	tco_timer_set_heartbeat(heartbeat);

	/*
	 * Stop the TCO before we change anything so we don't race with
	 * a zeroed timer.
	 */
	tco_timer_stop();

	/* Done */
	return 1;

unreg_mem_region:
	release_mem_region(tcobase_phys, SP5100_WDT_MEM_MAP_SIZE);
unreg_region:
	release_region(pm_iobase, SP5100_PM_IOPORTS_SIZE);
exit:
	return 0;
}

static int __devinit sp5100_tco_init(struct platform_device *dev)
{
	int ret;
	u32 val;

	/* Check whether or not the hardware watchdog is there. If found, then
	 * set it up.
	 */
	if (!sp5100_tco_setupdevice())
		return -ENODEV;

	/* Check to see if last reboot was due to watchdog timeout */
	printk(KERN_INFO PFX "Watchdog reboot %sdetected.\n",
	       readl(SP5100_WDT_CONTROL(tcobase)) & SP5100_PM_WATCHDOG_FIRED ?
		      "" : "not ");

	/* Clear out the old status */
	val = readl(SP5100_WDT_CONTROL(tcobase));
	val &= ~SP5100_PM_WATCHDOG_FIRED;
	writel(val, SP5100_WDT_CONTROL(tcobase));

	/*
	 * Check that the heartbeat value is within it's range.
	 * If not, reset to the default.
	 */
	if (tco_timer_set_heartbeat(heartbeat)) {
		heartbeat = WATCHDOG_HEARTBEAT;
		tco_timer_set_heartbeat(heartbeat);
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:67,代码来源:sp5100_tco.c

示例14: c4_add_card

static int c4_add_card(struct capicardparams *p, struct pci_dev *dev,
		       int nr_controllers)
{
	avmcard *card;
	avmctrl_info *cinfo;
	int retval;
	int i;

	card = b1_alloc_card(nr_controllers);
	if (!card) {
		printk(KERN_WARNING "c4: no memory.\n");
		retval = -ENOMEM;
		goto err;
	}
        card->dma = avmcard_dma_alloc("c4", dev, 2048+128, 2048+128);
	if (!card->dma) {
		printk(KERN_WARNING "c4: no memory.\n");
		retval = -ENOMEM;
		goto err_free;
	}

	sprintf(card->name, "c%d-%x", nr_controllers, p->port);
	card->port = p->port;
	card->irq = p->irq;
	card->membase = p->membase;
	card->cardtype = (nr_controllers == 4) ? avm_c4 : avm_c2;

	if (!request_region(card->port, AVMB1_PORTLEN, card->name)) {
		printk(KERN_WARNING "c4: ports 0x%03x-0x%03x in use.\n",
		       card->port, card->port + AVMB1_PORTLEN);
		retval = -EBUSY;
		goto err_free_dma;
	}

	card->mbase = ioremap(card->membase, 128);
	if (card->mbase == 0) {
		printk(KERN_NOTICE "c4: can't remap memory at 0x%lx\n",
		       card->membase);
		retval = -EIO;
		goto err_release_region;
	}

	retval = c4_detect(card);
	if (retval != 0) {
		printk(KERN_NOTICE "c4: NO card at 0x%x error(%d)\n",
		       card->port, retval);
		retval = -EIO;
		goto err_unmap;
	}
	c4_reset(card);

	retval = request_irq(card->irq, c4_interrupt, SA_SHIRQ, card->name, card);
	if (retval) {
		printk(KERN_ERR "c4: unable to get IRQ %d.\n",card->irq);
		retval = -EBUSY;
		goto err_unmap;
	}

	for (i=0; i < nr_controllers ; i++) {
		cinfo = &card->ctrlinfo[i];
		cinfo->capi_ctrl.owner = THIS_MODULE;
		cinfo->capi_ctrl.driver_name   = "c4";
		cinfo->capi_ctrl.driverdata    = cinfo;
		cinfo->capi_ctrl.register_appl = c4_register_appl;
		cinfo->capi_ctrl.release_appl  = c4_release_appl;
		cinfo->capi_ctrl.send_message  = c4_send_message;
		cinfo->capi_ctrl.load_firmware = c4_load_firmware;
		cinfo->capi_ctrl.reset_ctr     = c4_reset_ctr;
		cinfo->capi_ctrl.procinfo      = c4_procinfo;
		cinfo->capi_ctrl.ctr_read_proc = c4_read_proc;
		strcpy(cinfo->capi_ctrl.name, card->name);

		retval = attach_capi_ctr(&cinfo->capi_ctrl);
		if (retval) {
			printk(KERN_ERR "c4: attach controller failed (%d).\n", i);
			for (i--; i >= 0; i--) {
				cinfo = &card->ctrlinfo[i];
				detach_capi_ctr(&cinfo->capi_ctrl);
			}
			goto err_free_irq;
		}
		if (i == 0)
			card->cardnr = cinfo->capi_ctrl.cnr;
	}

	printk(KERN_INFO "c4: AVM C%d at i/o %#x, irq %d, mem %#lx\n",
	       nr_controllers, card->port, card->irq,
	       card->membase);
	pci_set_drvdata(dev, card);
	return 0;

 err_free_irq:
	free_irq(card->irq, card);
 err_unmap:
	iounmap(card->mbase);
 err_release_region:
	release_region(card->port, AVMB1_PORTLEN);
 err_free_dma:
	avmcard_dma_free(card->dma);
 err_free:
//.........这里部分代码省略.........
开发者ID:Dronevery,项目名称:JetsonTK1-kernel,代码行数:101,代码来源:c4.c

示例15: cleanup_module

void __exit cleanup_module(void)
{
	unregister_netdev(dev_ni52);
	release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE);
	free_netdev(dev_ni52);
}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:6,代码来源:ni52.c


注:本文中的release_region函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。