コード例 #1
0
ファイル: locking.c プロジェクト: the-snowwhite/linux-socfpga
/*
 * returns 1 if we get the read lock and 0 if we don't
 * this won't wait for blocking writers
 */
int btrfs_try_tree_read_lock(struct extent_buffer *eb)
{
	if (atomic_read(&eb->blocking_writers))
		return 0;

	if (!read_trylock(&eb->lock))
		return 0;

	if (atomic_read(&eb->blocking_writers)) {
		read_unlock(&eb->lock);
		return 0;
	}
	atomic_inc(&eb->read_locks);
	atomic_inc(&eb->spinning_readers);
	return 1;
}
コード例 #2
0
ファイル: hxge_main.c プロジェクト: u9621071/kernel-uek-UEK3
static void
hxge_work_to_do(struct work_struct *work)
#endif
{
	int i;
	int channel;

#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)
	struct hxge_adapter *hxgep = container_of(work, struct hxge_adapter, work_to_do);
#endif

	HXGE_ERR(hxgep, "hxge_work_to_do called on cpu %d",smp_processor_id());
	if (!read_trylock(&hxgep->wtd_lock)) {
		return;
	}

	for (i = 0; i < MAX_CMD; i++)
		if (test_and_clear_bit(i, &hxgep->work_q.command)) {
			switch (i) {
			   case RESET_TX_CHANNEL_0 :
			   case RESET_TX_CHANNEL_1 :
			   case RESET_TX_CHANNEL_2 :
			   case RESET_TX_CHANNEL_3 :
				channel =  i - RESET_TX_CHANNEL_0;
				HXGE_ERR(hxgep, "hxge_work_to_do: Resetting Tx channel %d", channel);
				hxge_reset_tx_channel(hxgep, channel);
				break;
			   case RESET_RX_CHANNEL_0 :
			   case RESET_RX_CHANNEL_1 :
			   case RESET_RX_CHANNEL_2 :
			   case RESET_RX_CHANNEL_3 :
				channel =  i - RESET_RX_CHANNEL_0;
				HXGE_ERR(hxgep, "hxge_work_to_do: Resetting Rx channel %d", channel);
				hxge_reset_rx_channel(hxgep, channel);
				break;
			   case RESET_ADAPTER:
				HXGE_ERR(hxgep, "hxge_work_to_do: Resetting adapter");
				hxge_reset_adapter(hxgep);
				break;
			   case RESET_TDC:
				HXGE_ERR(hxgep, "hxge_work_to_do: Resetting TDC core");
				hxge_reset_tdc(hxgep);
				break;
			   case RESET_RDC:
				HXGE_ERR(hxgep, "hxge_work_to_do: Resetting RDC core");
				hxge_reset_rdc(hxgep);
				break;
			   case RESET_PFC:
				/* For now, just reset the whole hxge */
				HXGE_ERR(hxgep, "hxge_work_to_do: Resetting PFC; resetting whole hxge");
				hxge_reset_adapter(hxgep);
				break;
			   case RESET_VMAC:
				/* For now, just reset the whole hxge */
				HXGE_ERR(hxgep, "hxge_work_to_do: Resetting VMAC; resetting whole hxge");
				hxge_reset_adapter(hxgep);
				break;
			   case SHUTDOWN_ADAPTER:
				HXGE_ERR(hxgep, "hxge_work_to_do: Shutting down adapter");
				hxge_shutdown_adapter(hxgep);
				break;
			   default:
				HXGE_ERR(hxgep, "hxge_work_to_do: Uh? unknown command");
				break;
			}
		}
	read_unlock(&hxgep->wtd_lock);
}