OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [block/] [paride/] [setup.h] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/*
2
        setup.h    (c) 1997-8   Grant R. Guenther <grant@torque.net>
3
                                Under the terms of the GNU public license.
4
 
5
        This is a table driven setup function for kernel modules
6
        using the module.variable=val,... command line notation.
7
 
8
*/
9
 
10
/* Changes:
11
 
12
        1.01    GRG 1998.05.05  Allow negative and defaulted values
13
 
14
*/
15
 
16
#include <linux/ctype.h>
17
#include <linux/string.h>
18
 
19
struct setup_tab_t {
20
 
21
        char    *tag;   /* variable name */
22
        int     size;   /* number of elements in array */
23
        int     *iv;    /* pointer to variable */
24
};
25
 
26
typedef struct setup_tab_t STT;
27
 
28
/*  t     is a table that describes the variables that can be set
29
          by gen_setup
30
    n     is the number of entries in the table
31
    ss    is a string of the form:
32
 
33
                <tag>=[<val>,...]<val>
34
*/
35
 
36
static void generic_setup( STT t[], int n, char *ss )
37
 
38
{       int     j,k, sgn;
39
 
40
        k = 0;
41
        for (j=0;j<n;j++) {
42
                k = strlen(t[j].tag);
43
                if (strncmp(ss,t[j].tag,k) == 0) break;
44
        }
45
        if (j == n) return;
46
 
47
        if (ss[k] == 0) {
48
                t[j].iv[0] = 1;
49
                return;
50
        }
51
 
52
        if (ss[k] != '=') return;
53
        ss += (k+1);
54
 
55
        k = 0;
56
        while (ss && (k < t[j].size)) {
57
                if (!*ss) break;
58
                sgn = 1;
59
                if (*ss == '-') { ss++; sgn = -1; }
60
                if (!*ss) break;
61
                if (isdigit(*ss))
62
                  t[j].iv[k] = sgn * simple_strtoul(ss,NULL,0);
63
                k++;
64
                if ((ss = strchr(ss,',')) != NULL) ss++;
65
        }
66
}
67
 
68
/* end of setup.h */
69
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.