Exemplo n.º 1
0
static void nfs4_shutdown_client(struct nfs_client *clp)
{
	if (__test_and_clear_bit(NFS_CS_RENEWD, &clp->cl_res_state))
		nfs4_kill_renewd(clp);
	nfs4_shutdown_session(clp);
	nfs4_destroy_callback(clp);
	if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
		nfs_idmap_delete(clp);

	rpc_destroy_wait_queue(&clp->cl_rpcwaitq);
	kfree(clp->cl_serverowner);
	kfree(clp->cl_serverscope);
	kfree(clp->cl_implid);
}
static void mpc8xxx_gpio_set_multiple(struct gpio_chip *gc,
				      unsigned long *mask, unsigned long *bits)
{
	struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
	struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
	unsigned long flags;
	int i;

	raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags);

	for (i = 0; i < gc->ngpio; i++) {
		if (*mask == 0)
			break;
		if (__test_and_clear_bit(i, mask)) {
			if (test_bit(i, bits))
				mpc8xxx_gc->data |= mpc8xxx_gpio2mask(i);
			else
				mpc8xxx_gc->data &= ~mpc8xxx_gpio2mask(i);
		}
	}

	out_be32(mm->regs + GPIO_DAT, mpc8xxx_gc->data);

	raw_spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags);
}
Exemplo n.º 3
0
/*
 * This is called by a user process when it sees the DISARM_BUFS event
 * bit is set.
 */
int qib_disarm_piobufs_ifneeded(struct qib_ctxtdata *rcd)
{
	struct qib_devdata *dd = rcd->dd;
	unsigned i;
	unsigned last;
	unsigned n = 0;

	last = rcd->pio_base + rcd->piocnt;
	/*
	 * Don't need uctxt_lock here, since user has called in to us.
	 * Clear at start in case more interrupts set bits while we
	 * are disarming
	 */
	if (rcd->user_event_mask) {
		/*
		 * subctxt_cnt is 0 if not shared, so do base
		 * separately, first, then remaining subctxt, if any
		 */
		clear_bit(_QIB_EVENT_DISARM_BUFS_BIT, &rcd->user_event_mask[0]);
		for (i = 1; i < rcd->subctxt_cnt; i++)
			clear_bit(_QIB_EVENT_DISARM_BUFS_BIT,
				  &rcd->user_event_mask[i]);
	}
	spin_lock_irq(&dd->pioavail_lock);
	for (i = rcd->pio_base; i < last; i++) {
		if (__test_and_clear_bit(i, dd->pio_need_disarm)) {
			n++;
			dd->f_sendctrl(rcd->ppd, QIB_SENDCTRL_DISARM_BUF(i));
		}
	}
	spin_unlock_irq(&dd->pioavail_lock);
	return 0;
}
Exemplo n.º 4
0
static void pm8921_chg_disable_irq(struct pm8921_chg_chip *chip, int interrupt)
{
	if (__test_and_clear_bit(interrupt, chip->enabled_irqs)) {
		dev_dbg(chip->dev, "%d\n", chip->pmic_chg_irq[interrupt]);
		disable_irq_nosync(chip->pmic_chg_irq[interrupt]);
	}
}
Exemplo n.º 5
0
/* Must be called hw IRQs off. */
void __ipipe_lock_irq(unsigned int irq)
{
	struct ipipe_domain *ipd = ipipe_root_domain;
	struct ipipe_percpu_domain_data *p;
	int l0b, l1b;

	IPIPE_WARN_ONCE(!hard_irqs_disabled());

	/*
	 * Interrupts requested by a registered head domain cannot be
	 * locked, since this would make no sense: interrupts are
	 * globally masked at CPU level when the head domain is
	 * stalled, so there is no way we could encounter the
	 * situation IRQ locks are handling.
	 */
	if (test_and_set_bit(IPIPE_LOCK_FLAG, &ipd->irqs[irq].control))
		return;

	l0b = irq / (BITS_PER_LONG * BITS_PER_LONG);
	l1b = irq / BITS_PER_LONG;

	p = ipipe_this_cpu_context(ipd);
	if (__test_and_clear_bit(irq, p->irqpend_lomap)) {
		__set_bit(irq, p->irqheld_map);
		if (p->irqpend_lomap[l1b] == 0) {
			__clear_bit(l1b, p->irqpend_mdmap);
			if (p->irqpend_mdmap[l0b] == 0)
				__clear_bit(l0b, &p->irqpend_himap);
		}
	}
}
Exemplo n.º 6
0
static void pm8058_chg_disable_irq(int interrupt)
{
	if (__test_and_clear_bit(interrupt, pm8058_chg.enabled_irqs)) {
		dev_dbg(pm8058_chg.dev, "%s %d\n", __func__,
			pm8058_chg.pmic_chg_irq[interrupt]);
		disable_irq_nosync(pm8058_chg.pmic_chg_irq[interrupt]);
	}
}
Exemplo n.º 7
0
static void test_and_clear_bit_test(int *bits, unsigned long *flags, int num)
{
	int i,
	    result = 1;

	for(i = 0; i < num; i++)
		result &= __test_and_clear_bit(bits[i], flags);

	assert(result && (flags[0] == 0UL && flags[1] == 0UL));
}
Exemplo n.º 8
0
static void rfkill_op_handler(struct work_struct *work)
{
	unsigned int i;
	bool c;

	spin_lock_irq(&rfkill_op_lock);
	do {
		if (rfkill_op_pending) {
			enum rfkill_sched_op op = rfkill_op;
			rfkill_op_pending = false;
			memset(rfkill_sw_pending, 0,
				sizeof(rfkill_sw_pending));
			spin_unlock_irq(&rfkill_op_lock);

			__rfkill_handle_global_op(op);

			spin_lock_irq(&rfkill_op_lock);

			/*
			 * handle global ops first -- during unlocked period
			 * we might have gotten a new global op.
			 */
			if (rfkill_op_pending)
				continue;
		}

		if (rfkill_is_epo_lock_active())
			continue;

		for (i = 0; i < NUM_RFKILL_TYPES; i++) {
			if (__test_and_clear_bit(i, rfkill_sw_pending)) {
				c = __test_and_clear_bit(i, rfkill_sw_state);
				spin_unlock_irq(&rfkill_op_lock);

				__rfkill_handle_normal_op(i, c);

				spin_lock_irq(&rfkill_op_lock);
			}
		}
	} while (rfkill_op_pending);
	spin_unlock_irq(&rfkill_op_lock);
}
Exemplo n.º 9
0
static void dealloc_unique_number(struct unique_numspace *s, int number)
{
	int old_val;

	if (number >= 0) {
		down(&numspace_mutex);
		old_val = __test_and_clear_bit(number, s->bits);
		if (old_val)
			++s->num_free;
		up(&numspace_mutex);
	}
}
Exemplo n.º 10
0
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer)
{
	int out=0, in;
	int key_index;
	int gpio;
	struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer);
	struct gpio_event_matrix_info *mi = kp->keypad_info;
	unsigned gpio_keypad_flags = mi->flags;
	unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH);

		kp->last_key_state_changed = kp->key_state_changed;
		kp->key_state_changed = 0;
		kp->some_keys_pressed = 0;
		key_index = 0;
		for (in = 0; in < mi->ninputs; in++, key_index++) {
			gpio = mi->input_gpios[in];
			if (gpio_get_value(gpio) ^ !polarity) {
				if (kp->some_keys_pressed < 3)
					kp->some_keys_pressed++;
				kp->key_state_changed |= !__test_and_set_bit(
						key_index, kp->keys_pressed);
			} else
				kp->key_state_changed |= __test_and_clear_bit(
						key_index, kp->keys_pressed);
		}

	if (gpio_keypad_flags & GPIOKPF_DEBOUNCE) {
		if (kp->key_state_changed) {
			hrtimer_start(&kp->timer, mi->debounce_delay,
				      HRTIMER_MODE_REL);
			return HRTIMER_NORESTART;
		}
		kp->key_state_changed = kp->last_key_state_changed;
	}
	if (kp->key_state_changed) {
		if (gpio_keypad_flags & GPIOKPF_REMOVE_SOME_PHANTOM_KEYS)
			remove_phantom_keys(kp);
		key_index = 0;
			for (in = 0; in < mi->ninputs; in++, key_index++)
				report_key(kp, key_index, out, in);
	}
	if (!kp->use_irq || kp->some_keys_pressed) {
		hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL);
		return HRTIMER_NORESTART;
	}

	/* No keys are pressed, reenable interrupt */
	for (in = 0; in < mi->ninputs; in++)
		enable_irq(gpio_to_irq(mi->input_gpios[in]));
	wake_unlock(&kp->wake_lock);
	return HRTIMER_NORESTART;
}
Exemplo n.º 11
0
static void ack_work(struct work_struct *work)
{
    struct pptp_opt *opt=container_of(work,struct pptp_opt,ack_work);
    struct pppox_sock *po=container_of(opt,struct pppox_sock,proto.pptp);
#else
static void ack_work(struct pppox_sock *po)
{
	struct pptp_opt *opt=&po->proto.pptp;
#endif
	INC_ACK_WORKS;
	pptp_xmit(&po->chan,0);

	if (!test_and_set_bit(PPTP_FLAG_PROC,(unsigned long*)&opt->flags)){
		if (ppp_unit_number(&po->chan)!=-1){
			char unit[10];
			sprintf(unit,"ppp%i",ppp_unit_number(&po->chan));
			create_proc_read_entry(unit,0,proc_dir,read_proc,po);
		}else clear_bit(PPTP_FLAG_PROC,(unsigned long*)&opt->flags);
	}
}


static void do_ack_timeout_work(struct pppox_sock *po)
{
    struct pptp_opt *opt=&po->proto.pptp;
    int paused;
    
    spin_lock_bh(&opt->xmit_lock);
    paused=__test_and_clear_bit(PPTP_FLAG_PAUSE,(unsigned long*)&opt->flags);
    if (paused){
			if (opt->window>min_window) --opt->window;
			opt->ack_recv=opt->seq_sent;
    }
    spin_unlock_bh(&opt->xmit_lock);
    if (paused) ppp_output_wakeup(&po->chan);
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
static void _ack_timeout_work(struct work_struct *work)
{
    struct pptp_opt *opt=container_of(work,struct pptp_opt,ack_timeout_work.work);
    struct pppox_sock *po=container_of(opt,struct pppox_sock,proto.pptp);
		INC_ACK_TIMEOUTS;
    do_ack_timeout_work(po);
}
#else
static void _ack_timeout_work(struct pppox_sock *po)
{
	INC_ACK_TIMEOUTS;
  do_ack_timeout_work(po);
}
Exemplo n.º 12
0
void drbd_bm_unlock(struct drbd_conf *mdev)
{
    struct drbd_bitmap *b = mdev->bitmap;
    if (!b) {
        dev_err(DEV, "FIXME no bitmap in drbd_bm_unlock!?\n");
        return;
    }

    if (!__test_and_clear_bit(BM_LOCKED, &mdev->bitmap->bm_flags))
        dev_err(DEV, "FIXME bitmap not locked in bm_unlock\n");

    b->bm_why  = NULL;
    b->bm_task = NULL;
    mutex_unlock(&b->bm_change);
}
Exemplo n.º 13
0
void hvm_isa_irq_deassert(
    struct domain *d, unsigned int isa_irq)
{
    struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
    unsigned int gsi = hvm_isa_irq_to_gsi(isa_irq);

    ASSERT(isa_irq <= 15);

    spin_lock(&d->arch.hvm_domain.irq_lock);

    if ( __test_and_clear_bit(isa_irq, &hvm_irq->isa_irq.i) &&
            (--hvm_irq->gsi_assert_count[gsi] == 0) )
        deassert_irq(d, isa_irq);

    spin_unlock(&d->arch.hvm_domain.irq_lock);
}
Exemplo n.º 14
0
void hvm_pci_intx_deassert(
        struct domain *d, unsigned int device, unsigned int intx)
{
    struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
    unsigned int gsi;

    ASSERT((device <= 31) && (intx <= 3));

    if ( !__test_and_clear_bit(device * 4 + intx, &hvm_irq->pci_intx.i) )
        return;

    gsi = hvm_pci_intx_gsi(device, intx);

    if (--hvm_irq->gsi_assert_count[gsi] == 0)
        viosapic_set_irq(d, gsi, 0);
}
Exemplo n.º 15
0
/**
 * hpsb_free_tlabel - free an allocated transaction label
 * @packet: packet whose tlabel and tl_pool needs to be cleared
 *
 * Frees the transaction label allocated with hpsb_get_tlabel().  The
 * tlabel has to be freed after the transaction is complete (i.e. response
 * was received for a split transaction or packet was sent for a unified
 * transaction).
 *
 * A tlabel must not be freed twice.
 */
void hpsb_free_tlabel(struct hpsb_packet *packet)
{
	unsigned long flags, *tp;
	int tlabel, n = NODEID_TO_NODE(packet->node_id);

	if (unlikely(n == ALL_NODES))
		return;
	tp = packet->host->tl_pool[n].map;
	tlabel = packet->tlabel;
	BUG_ON(tlabel > 63 || tlabel < 0);

	spin_lock_irqsave(&hpsb_tlabel_lock, flags);
	BUG_ON(!__test_and_clear_bit(tlabel, tp));
	spin_unlock_irqrestore(&hpsb_tlabel_lock, flags);

	wake_up_interruptible(&tlabel_wq);
}
Exemplo n.º 16
0
int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
{
	struct rt2x00_dev *rt2x00dev = hw->priv;
	int force_reconfig;

	/*
	 * Mac80211 might be calling this function while we are trying
	 * to remove the device or perhaps suspending it.
	 */
	if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags))
		return 0;

	/*
	 * Check if we need to disable the radio,
	 * if this is not the case, at least the RX must be disabled.
	 */
	if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) {
		if (!conf->radio_enabled)
			rt2x00lib_disable_radio(rt2x00dev);
		else
			rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
	}

	/*
	 * When the DEVICE_DIRTY_CONFIG flag is set, the device has recently
	 * been started and the configuration must be forced upon the hardware.
	 * Otherwise registers will not be intialized correctly and could
	 * result in non-working hardware because essential registers aren't
	 * initialized.
	 */
	force_reconfig =
	    __test_and_clear_bit(DEVICE_DIRTY_CONFIG, &rt2x00dev->flags);

	rt2x00lib_config(rt2x00dev, conf, force_reconfig);

	/*
	 * Reenable RX only if the radio should be on.
	 */
	if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
		rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
	else if (conf->radio_enabled)
		return rt2x00lib_enable_radio(rt2x00dev);

	return 0;
}
Exemplo n.º 17
0
void __init microcode_grab_module(
    unsigned long *module_map,
    const multiboot_info_t *mbi,
    void *(*map)(const module_t *))
{
    module_t *mod = (module_t *)__va(mbi->mods_addr);

    if ( ucode_mod_idx < 0 )
        ucode_mod_idx += mbi->mods_count;
    if ( ucode_mod_idx <= 0 || ucode_mod_idx >= mbi->mods_count ||
         !__test_and_clear_bit(ucode_mod_idx, module_map) )
        goto scan;
    ucode_mod = mod[ucode_mod_idx];
    ucode_mod_map = map;
scan:
    if ( ucode_scan )
        microcode_scan_module(module_map, mbi, map);
}
Exemplo n.º 18
0
/* Must be called hw IRQs off. */
void __ipipe_lock_irq(unsigned int irq)
{
	struct ipipe_percpu_domain_data *p;
	int l0b = irq / BITS_PER_LONG;

	IPIPE_WARN_ONCE(!hard_irqs_disabled());

	if (test_and_set_bit(IPIPE_LOCK_FLAG,
			     &ipipe_root_domain->irqs[irq].control))
		return;

	p = ipipe_this_cpu_root_context();
	if (__test_and_clear_bit(irq, p->irqpend_lomap)) {
		__set_bit(irq, p->irqheld_map);
		if (p->irqpend_lomap[l0b] == 0)
			__clear_bit(l0b, &p->irqpend_himap);
	}
}
Exemplo n.º 19
0
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer)
{
	int out, in;
	int key_index;
	int gpio;
	struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer);
	struct gpio_event_matrix_info *mi = kp->keypad_info;
	unsigned gpio_keypad_flags = mi->flags;
	unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH);

	out = kp->current_output;
	if (out == mi->noutputs) {
		out = 0;
		kp->last_key_state_changed = kp->key_state_changed;
		kp->key_state_changed = 0;
		kp->some_keys_pressed = 0;
	} else {
		key_index = out * mi->ninputs;
		for (in = 0; in < mi->ninputs; in++, key_index++) {
			gpio = mi->input_gpios[in];
			if (gpio_get_value(gpio) ^ !polarity) {
				if (kp->some_keys_pressed < 3)
					kp->some_keys_pressed++;
				kp->key_state_changed |= !__test_and_set_bit(
						key_index, kp->keys_pressed);
			} else
				kp->key_state_changed |= __test_and_clear_bit(
						key_index, kp->keys_pressed);
		}
		gpio = mi->output_gpios[out];
		if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE)
#ifdef ROW_SCAN   //ZTE_KB_ZFJ_20110325
		{
			gpio_set_value(gpio, !polarity);
			gpio_direction_input(gpio);
		}
#else
			gpio_set_value(gpio, !polarity);
#endif	
		else
			gpio_direction_input(gpio);
		out++;
	}
Exemplo n.º 20
0
/*
 * TX data handlers.
 */
static void rt2x00usb_interrupt_txdone(struct urb *urb)
{
	struct queue_entry *entry = (struct queue_entry *)urb->context;
	struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
	struct queue_entry_priv_usb_tx *priv_tx = entry->priv_data;
	struct txdone_entry_desc txdesc;
	__le32 *txd = (__le32 *)entry->skb->data;
	u32 word;

	if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) ||
	    !__test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
		return;

	rt2x00_desc_read(txd, 0, &word);

	/*
	 * Remove the descriptor data from the buffer.
	 */
	skb_pull(entry->skb, entry->queue->desc_size);

	/*
	 * Obtain the status about this packet.
	 */
	txdesc.status = !urb->status ? TX_SUCCESS : TX_FAIL_RETRY;
	txdesc.retry = 0;
	txdesc.control = &priv_tx->control;

	rt2x00lib_txdone(entry, &txdesc);

	/*
	 * Make this entry available for reuse.
	 */
	entry->flags = 0;
	rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE);

	/*
	 * If the data queue was full before the txdone handler
	 * we must make sure the packet queue in the mac80211 stack
	 * is reenabled when the txdone handler has finished.
	 */
	if (!rt2x00queue_full(entry->queue))
		ieee80211_wake_queue(rt2x00dev->hw, priv_tx->control.queue);
}
Exemplo n.º 21
0
/*
 * Initialization/uninitialization handlers.
 */
static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
{
	if (!__test_and_clear_bit(DEVICE_INITIALIZED, &rt2x00dev->flags))
		return;

	/*
	 * Unregister extra components.
	 */
	rt2x00rfkill_unregister(rt2x00dev);

	/*
	 * Allow the HW to uninitialize.
	 */
	rt2x00dev->ops->lib->uninitialize(rt2x00dev);

	/*
	 * Free allocated queue entries.
	 */
	rt2x00queue_uninitialize(rt2x00dev);
}
Exemplo n.º 22
0
static void __hvm_pci_intx_deassert(
    struct domain *d, unsigned int device, unsigned int intx)
{
    struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
    unsigned int gsi, link, isa_irq;

    ASSERT((device <= 31) && (intx <= 3));

    if ( !__test_and_clear_bit(device*4 + intx, &hvm_irq->pci_intx.i) )
        return;

    gsi = hvm_pci_intx_gsi(device, intx);
    --hvm_irq->gsi_assert_count[gsi];

    link    = hvm_pci_intx_link(device, intx);
    isa_irq = hvm_irq->pci_link.route[link];
    if ( (--hvm_irq->pci_link_assert_count[link] == 0) && isa_irq &&
            (--hvm_irq->gsi_assert_count[isa_irq] == 0) )
        deassert_irq(d, isa_irq);
}
Exemplo n.º 23
0
Arquivo: bitmap.c Projeto: tliu526/a5
/**
 * wufs_free_inode: (utility routine)
 * Reverse the effects of wufs_new_inode.
 */
void wufs_free_inode(struct inode * inode)
{
  struct wufs_sb_info *sbi = wufs_sb(inode->i_sb);
  struct buffer_head *bh;
  int bits_per_block = 8 * WUFS_BLOCKSIZE;
  unsigned long ino, bit, mapBlock;

  /* grab the inode *number* */
  ino = inode->i_ino;
  if (ino < 1 || ino > sbi->sbi_inodes) {
    printk("wufs_free_inode: nonexistent inode (%lu)\n",ino);
    goto out;
  }

  /* we now compute the inode index as a block and bit offset */
  ino--;
  bit = ino % bits_per_block;
  mapBlock = ino/bits_per_block;
  if (mapBlock >= sbi->sbi_imap_bcnt) {
    printk("wufs_free_inode: nonexistent imap block (%lu) in superblock\n",
	   mapBlock);
    goto out;
  }

  /* mark the on-disk inode as free */
  wufs_clear_inode(inode);

  /* now, clear the associated bit */
  bh = sbi->sbi_imap[mapBlock];

  spin_lock(&bitmap_lock);
  /* clear the bit: */
  if (!__test_and_clear_bit(bit, (unsigned long*)bh->b_data))
    printk("wufs_free_inode: bit %lu already cleared\n", bit);
  spin_unlock(&bitmap_lock);
  /* write back bitmap */
  mark_buffer_dirty(bh);
 out:
  /* clear the vfs inode, marking it for deletion (see linux/fs/inode.c) */
  clear_inode(inode);
}
Exemplo n.º 24
0
static void bgpio_multiple_get_masks(struct bgpio_chip *bgc,
				     unsigned long *mask, unsigned long *bits,
				     unsigned long *set_mask,
				     unsigned long *clear_mask)
{
	int i;

	*set_mask = 0;
	*clear_mask = 0;

	for (i = 0; i < bgc->bits; i++) {
		if (*mask == 0)
			break;
		if (__test_and_clear_bit(i, mask)) {
			if (test_bit(i, bits))
				*set_mask |= bgc->pin2mask(bgc, i);
			else
				*clear_mask |= bgc->pin2mask(bgc, i);
		}
	}
}
Exemplo n.º 25
0
void vm_free(const void *va)
{
    unsigned int bit = vm_index(va);

    if ( !bit )
    {
        WARN_ON(va != NULL);
        return;
    }

    spin_lock(&vm_lock);
    if ( bit < vm_low )
    {
        vm_low = bit - 1;
        while ( !test_bit(vm_low - 1, vm_bitmap) )
            --vm_low;
    }
    while ( __test_and_clear_bit(bit, vm_bitmap) )
        if ( ++bit == vm_top )
            break;
    spin_unlock(&vm_lock);
}
Exemplo n.º 26
0
Arquivo: bitmap.c Projeto: tliu526/a5
/**
 * wufs_free_block: (utility function)
 * Undoes the accounting of allocating a block.
 * Simply: clear the bit at the appropriate offset in the bitmap.
 */
void wufs_free_block(struct inode *inode, unsigned long block)
{
  /* grab our local info structures */
  struct super_block *sb = inode->i_sb;
  struct wufs_sb_info *sbi = wufs_sb(sb);
  struct buffer_head *bh;
  int bits_per_block = 8 * inode->i_sb->s_blocksize;
  unsigned long bit, mapBlock;
  int previous;

  /* sanity check: we're only working with data blocks */
  if (block < sbi->sbi_first_block || block >= sbi->sbi_blocks) {
    printk("wufs_free_block: Trying to free non-data block %lu\n",block);
    return;
  }

  /* break bit offset into block offset in map and bit offset in block */
  bit = block % bits_per_block;
  mapBlock = block/bits_per_block;
  if (mapBlock >= sbi->sbi_bmap_bcnt) {
    printk("wufs_free_block: nonexistent bitmap buffer, %lu\n",mapBlock);
    return;
  }
  /* grab the buffer head */
  bh = sbi->sbi_bmap[mapBlock];

  /* get exclusive access */
  spin_lock(&bitmap_lock);
  previous = __test_and_clear_bit(bit, (unsigned long*)bh->b_data); /* see <linux/Documentation/atomic_ops.txt> */
  spin_unlock(&bitmap_lock);
  
  /* check status (outside the critical section!) */
  if (!previous) printk("wufs_free_block (%s:%lu): bit already cleared\n",
			sb->s_id, block);

  /* flush bitmap buffer */
  mark_buffer_dirty(bh);
  return;
}
Exemplo n.º 27
0
void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
{
	if (!__test_and_clear_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
		return;

	/*
	 * Stop the TX queues.
	 */
	ieee80211_stop_queues(rt2x00dev->hw);

	/*
	 * Disable RX.
	 */
	rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);

	/*
	 * Disable radio.
	 */
	rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_OFF);
	rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_IRQ_OFF);
	rt2x00led_led_activity(rt2x00dev, false);
	rt2x00leds_led_radio(rt2x00dev, false);
}
Exemplo n.º 28
0
/**
 * xgpio_set_multiple - Write the specified signals of the GPIO device.
 * @gc:     Pointer to gpio_chip device structure.
 * @mask:   Mask of the GPIOS to modify.
 * @bits:   Value to be wrote on each GPIO
 *
 * This function writes the specified values into the specified signals of the
 * GPIO devices.
 */
static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
			       unsigned long *bits)
{
	unsigned long flags;
	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
	struct xgpio_instance *chip = gpiochip_get_data(gc);
	int index = xgpio_index(chip, 0);
	int offset, i;

	spin_lock_irqsave(&chip->gpio_lock[index], flags);

	/* Write to GPIO signals */
	for (i = 0; i < gc->ngpio; i++) {
		if (*mask == 0)
			break;
		if (index !=  xgpio_index(chip, i)) {
			xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET +
				       xgpio_regoffset(chip, i),
				       chip->gpio_state[index]);
			spin_unlock_irqrestore(&chip->gpio_lock[index], flags);
			index =  xgpio_index(chip, i);
			spin_lock_irqsave(&chip->gpio_lock[index], flags);
		}
		if (__test_and_clear_bit(i, mask)) {
			offset =  xgpio_offset(chip, i);
			if (test_bit(i, bits))
				chip->gpio_state[index] |= BIT(offset);
			else
				chip->gpio_state[index] &= ~BIT(offset);
		}
	}

	xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET +
		       xgpio_regoffset(chip, i), chip->gpio_state[index]);

	spin_unlock_irqrestore(&chip->gpio_lock[index], flags);
}
Exemplo n.º 29
0
/*
 * Destroy the NFS4 callback service
 */
static void nfs4_destroy_callback(struct nfs_client *clp)
{
	if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
		nfs_callback_down(clp->cl_mvops->minor_version, clp->cl_net);
}
Exemplo n.º 30
0
static enum hrtimer_restart gpio_keypad_timer_func(struct hrtimer *timer)
{
	int out, in;
	int key_index;
	int gpio;
	struct gpio_kp *kp = container_of(timer, struct gpio_kp, timer);
	struct gpio_event_matrix_info *mi = kp->keypad_info;
	unsigned gpio_keypad_flags = mi->flags;
#ifdef CONFIG_ZTE_PLATFORM
	unsigned polarity = !!(gpio_keypad_flags & !GPIOKPF_ACTIVE_HIGH);
#else
	unsigned polarity = !!(gpio_keypad_flags & GPIOKPF_ACTIVE_HIGH);
#endif

	out = kp->current_output;
	if (out == mi->noutputs) {
		out = 0;
		kp->last_key_state_changed = kp->key_state_changed;
		kp->key_state_changed = 0;
		kp->some_keys_pressed = 0;
	} else {
		key_index = out * mi->ninputs;
		for (in = 0; in < mi->ninputs; in++, key_index++) {
			gpio = mi->input_gpios[in];
			if (gpio_get_value(gpio) ^ !polarity) {
				if (kp->some_keys_pressed < 3)
					kp->some_keys_pressed++;
				kp->key_state_changed |= !__test_and_set_bit(
						key_index, kp->keys_pressed);
			} else
				kp->key_state_changed |= __test_and_clear_bit(
						key_index, kp->keys_pressed);
		}
		gpio = mi->output_gpios[out];
		if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE)
			gpio_set_value(gpio, !polarity);
		else
			gpio_direction_input(gpio);
		out++;
	}
	kp->current_output = out;
	if (out < mi->noutputs) {
		gpio = mi->output_gpios[out];
		if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE)
			gpio_set_value(gpio, polarity);
		else
			gpio_direction_output(gpio, polarity);
		hrtimer_start(timer, mi->settle_time, HRTIMER_MODE_REL);
		return HRTIMER_NORESTART;
	}
	if (gpio_keypad_flags & GPIOKPF_DEBOUNCE) {
		if (kp->key_state_changed) {
			hrtimer_start(&kp->timer, mi->debounce_delay,
				      HRTIMER_MODE_REL);
			return HRTIMER_NORESTART;
		}
		kp->key_state_changed = kp->last_key_state_changed;
	}
	if (kp->key_state_changed) {
		if (gpio_keypad_flags & GPIOKPF_REMOVE_SOME_PHANTOM_KEYS)
			remove_phantom_keys(kp);
		key_index = 0;
		for (out = 0; out < mi->noutputs; out++)
			for (in = 0; in < mi->ninputs; in++, key_index++)
				report_key(kp, key_index, out, in);
	}
	if (!kp->use_irq || kp->some_keys_pressed) {
		hrtimer_start(timer, mi->poll_time, HRTIMER_MODE_REL);
		return HRTIMER_NORESTART;
	}

	/* No keys are pressed, reenable interrupt */
	for (out = 0; out < mi->noutputs; out++) {
		if (gpio_keypad_flags & GPIOKPF_DRIVE_INACTIVE)
			gpio_set_value(mi->output_gpios[out], polarity);
		else
			gpio_direction_output(mi->output_gpios[out], polarity);
	}
	for (in = 0; in < mi->ninputs; in++)
		enable_irq(gpio_to_irq(mi->input_gpios[in]));
	wake_unlock(&kp->wake_lock);
	return HRTIMER_NORESTART;
}