How convert char[] to int in linux kernel
with validation that the text entered is actually an int?
int procfile_write(struct file *file, const char
I use sscanf() (the kernel version) to scan from a string stream, and it works on 2.6.39-gentoo-r3. Frankly, I could never get simple_strtol() to work in the kernel--I am currently figuring out why this doesn't work on my box.
...
memcpy(bufActual, calc_buffer, calc_buffer_size);
/* a = simple_strtol(bufActual, NULL, 10); */ // Could not get this to work
sscanf(bufActual, "%c%ld", &opr, &a); // places '+' in opr and a=20 for bufActual = "20+\0"
...