Re: Module parameters set and get functions for basic data types are missing.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

The param_{set, get}_<basic_types> functions are created using the macro below and hence these functions are not seen in the kernel/params.c file.

Here is the relevant code snippet:

/* Lazy bastard, eh? */
#define STANDARD_PARAM_DEF(name, type, format, tmptype, strtolfn)       \
        int param_set_##name(const char *val, struct kernel_param *kp)  \
        {                                                               \
                char *endp;                                             \
                tmptype l;                                              \
                                                                        \
                if (!val) return -EINVAL;                               \
                l = strtolfn(val, &endp, 0);                            \
                if (endp == val || ((type)l != l))                      \
                        return -EINVAL;                                 \
                *((type *)kp->arg) = l;                                 \
                return 0;                                               \
        }                                                               \
        int param_get_##name(char *buffer, struct kernel_param *kp)     \
        {                                                               \
                return sprintf(buffer, format, *((type *)kp->arg));     \
        }

STANDARD_PARAM_DEF(byte, unsigned char, "%c", unsigned long, simple_strtoul);
STANDARD_PARAM_DEF(short, short, "%hi", long, simple_strtol);
STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, simple_strtoul);
STANDARD_PARAM_DEF(int, int, "%i", long, simple_strtol);
STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, simple_strtoul);
STANDARD_PARAM_DEF(long, long, "%li", long, simple_strtol);
STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, simple_strtoul);

Thanks and Regards,
Prasad.

On 6/5/07, Prasad Joshi <prasadjoshi124@xxxxxxxxx> wrote:
Hi All,

I was trying to understand how the module parameters are implemented ( include/linux/moduleparam.h). The kernel supports following types of module parameters by default
BASIC TYPES ==> int, long, short, uint, ulong, ushort, byte
AND also ==> bool, invbool, charp, array, copystring, string

For each of these data types there are two functions declared in the file "include/linux/moduleparam.h" as following

extern int param_set_byte(const char *val, struct kernel_param *kp);
extern int param_get_byte(char *buffer, struct kernel_param *kp);

similarly, these two functions set and get are declared for each type supported by the kernel
( param_set_##type, param_get_##type )

Some of these functions are implemented in the file "./kernel/params.c", but all of the basic data types related function are missing from the kernel source

ie. I am able to find the definition of set and get function for bool, invbool, charp, array, copystring, string in file "./kernel/params.c" but, the corresponding set and get functions for basic data types are missing.

Now, the question is how the kernel support these data types and why those functions are declared but, their definition is missing?

Thanks and Regards,
Prasad.


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux