aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/tidspbridge/gen
diff options
context:
space:
mode:
authorIonut Nicu <ionut.nicu@gmail.com>2010-11-21 05:46:22 -0500
committerOmar Ramirez Luna <omar.ramirez@ti.com>2011-02-04 21:11:33 -0500
commit6d7e925b88cd8436b1284158876580ea431cb954 (patch)
tree8276e3a240d35518e9578bf2b24ed5968e979c72 /drivers/staging/tidspbridge/gen
parentb5a38abad033f6075e2c4cbfc4507cc7e82c36d2 (diff)
staging: tidspbridge: remove gb bitmap implementation
Now that all users of gb have been converted to the standard linux bitmap API, we can remove it from the gen library. Signed-off-by: Ionut Nicu <ionut.nicu@mindbit.ro> Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
Diffstat (limited to 'drivers/staging/tidspbridge/gen')
-rw-r--r--drivers/staging/tidspbridge/gen/gb.c165
1 files changed, 0 insertions, 165 deletions
diff --git a/drivers/staging/tidspbridge/gen/gb.c b/drivers/staging/tidspbridge/gen/gb.c
deleted file mode 100644
index 3c0e04cc2b0..00000000000
--- a/drivers/staging/tidspbridge/gen/gb.c
+++ /dev/null
@@ -1,165 +0,0 @@
1/*
2 * gb.c
3 *
4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5 *
6 * Generic bitmap operations.
7 *
8 * Copyright (C) 2005-2006 Texas Instruments, Inc.
9 *
10 * This package is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 */
18
19/* ----------------------------------- DSP/BIOS Bridge */
20#include <linux/types.h>
21/* ----------------------------------- This */
22#include <dspbridge/gb.h>
23
24struct gb_t_map {
25 u32 len;
26 u32 wcnt;
27 u32 *words;
28};
29
30/*
31 * ======== gb_clear ========
32 * purpose:
33 * Clears a bit in the bit map.
34 */
35
36void gb_clear(struct gb_t_map *map, u32 bitn)
37{
38 u32 mask;
39
40 mask = 1L << (bitn % BITS_PER_LONG);
41 map->words[bitn / BITS_PER_LONG] &= ~mask;
42}
43
44/*
45 * ======== gb_create ========
46 * purpose:
47 * Creates a bit map.
48 */
49
50struct gb_t_map *gb_create(u32 len)
51{
52 struct gb_t_map *map;
53 u32 i;
54 map = kzalloc(sizeof(struct gb_t_map), GFP_KERNEL);
55 if (map != NULL) {
56 map->len = len;
57 map->wcnt = len / BITS_PER_LONG + 1;
58 map->words = kzalloc(map->wcnt * sizeof(u32), GFP_KERNEL);
59 if (map->words != NULL) {
60 for (i = 0; i < map->wcnt; i++)
61 map->words[i] = 0L;
62
63 } else {
64 kfree(map);
65 map = NULL;
66 }
67 }
68
69 return map;
70}
71
72/*
73 * ======== gb_delete ========
74 * purpose:
75 * Frees a bit map.
76 */
77
78void gb_delete(struct gb_t_map *map)
79{
80 kfree(map->words);
81 kfree(map);
82}
83
84/*
85 * ======== gb_findandset ========
86 * purpose:
87 * Finds a free bit and sets it.
88 */
89u32 gb_findandset(struct gb_t_map *map)
90{
91 u32 bitn;
92
93 bitn = gb_minclear(map);
94
95 if (bitn != GB_NOBITS)
96 gb_set(map, bitn);
97
98 return bitn;
99}
100
101/*
102 * ======== gb_minclear ========
103 * purpose:
104 * returns the location of the first unset bit in the bit map.
105 */
106u32 gb_minclear(struct gb_t_map *map)
107{
108 u32 bit_location = 0;
109 u32 bit_acc = 0;
110 u32 i;
111 u32 bit;
112 u32 *word;
113
114 for (word = map->words, i = 0; i < map->wcnt; word++, i++) {
115 if (~*word) {
116 for (bit = 0; bit < BITS_PER_LONG; bit++, bit_acc++) {
117 if (bit_acc == map->len)
118 return GB_NOBITS;
119
120 if (~*word & (1L << bit)) {
121 bit_location = i * BITS_PER_LONG + bit;
122 return bit_location;
123 }
124
125 }
126 } else {
127 bit_acc += BITS_PER_LONG;
128 }
129 }
130
131 return GB_NOBITS;
132}
133
134/*
135 * ======== gb_set ========
136 * purpose:
137 * Sets a bit in the bit map.
138 */
139
140void gb_set(struct gb_t_map *map, u32 bitn)
141{
142 u32 mask;
143
144 mask = 1L << (bitn % BITS_PER_LONG);
145 map->words[bitn / BITS_PER_LONG] |= mask;
146}
147
148/*
149 * ======== gb_test ========
150 * purpose:
151 * Returns true if the bit is set in the specified location.
152 */
153
154bool gb_test(struct gb_t_map *map, u32 bitn)
155{
156 bool state;
157 u32 mask;
158 u32 word;
159
160 mask = 1L << (bitn % BITS_PER_LONG);
161 word = map->words[bitn / BITS_PER_LONG];
162 state = word & mask ? true : false;
163
164 return state;
165}