aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/pcxhr/pcxhr.h
Commit message (Expand)AuthorAge
* Merge branch 'topic/pcxhr' into for-linusTakashi Iwai2009-03-23
|\
| * ALSA: pcxhr - add support for gpio ports and minor bug fixMarkus Bollinger2009-01-23
* | ALSA: pcxhr.h replace signed one-bit bitfieldsHarvey Harrison2009-02-20
|/
* ALSA: pcxhr - add support for pcxhr stereo sound cards (core change)Markus Bollinger2008-11-25
* [ALSA] semaphore -> mutex (PCI part)Ingo Molnar2006-03-22
* [ALSA] Add PCXHR driverMarkus Bollinger2006-01-03
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
/*
 * cpu_rmap.c: CPU affinity reverse-map support
 * Copyright 2011 Solarflare Communications Inc.
 *
 * 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, incorporated herein by reference.
 */

#include <linux/cpumask.h>
#include <linux/gfp.h>
#include <linux/slab.h>

/**
 * struct cpu_rmap - CPU affinity reverse-map
 * @size: Number of objects to be reverse-mapped
 * @used: Number of objects added
 * @obj: Pointer to array of object pointers
 * @near: For each CPU, the index and distance to the nearest object,
 *      based on affinity masks
 */
struct cpu_rmap {
	u16		size, used;
	void		**obj;
	struct {
		u16	index;
		u16	dist;
	}		near[0];
};
#define CPU_RMAP_DIST_INF 0xffff

extern struct cpu_rmap *alloc_cpu_rmap(unsigned int size, gfp_t flags);

/**
 * free_cpu_rmap - free CPU affinity reverse-map
 * @rmap: Reverse-map allocated with alloc_cpu_rmap(), or %NULL
 */
static inline void free_cpu_rmap(struct cpu_rmap *rmap)
{
	kfree(rmap);
}

extern int cpu_rmap_add(struct cpu_rmap *rmap, void *obj);
extern int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,
			   const struct cpumask *affinity);

static inline u16 cpu_rmap_lookup_index(struct cpu_rmap *rmap, unsigned int cpu)
{
	return rmap->near[cpu].index;
}

static inline void *cpu_rmap_lookup_obj(struct cpu_rmap *rmap, unsigned int cpu)
{
	return rmap->obj[rmap->near[cpu].index];
}

#ifdef CONFIG_GENERIC_HARDIRQS

/**
 * alloc_irq_cpu_rmap - allocate CPU affinity reverse-map for IRQs
 * @size: Number of objects to be mapped
 *
 * Must be called in process context.
 */
static inline struct cpu_rmap *alloc_irq_cpu_rmap(unsigned int size)
{
	return alloc_cpu_rmap(size, GFP_KERNEL);
}
extern void free_irq_cpu_rmap(struct cpu_rmap *rmap);

extern int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq);

#endif