linux-device-driver

kernel driver reading ok from user space, but writing back is always 0

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 05:45:58
So I'm working my way through kernel driver programming, and currently I'm trying to build a simple data transfer between application and kernel driver. I am using simple character device as a link between these two, and I have succeeded to transfer data to driver, but I can't get meaningful data back to user space. Kernel driver looks like this: #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> /* printk() */ #include <linux/errno.h> /* error codes */ #include <linux/types.h> /* size_t */ #include <linux/proc_fs.h> #include <asm/uaccess.h> /* copy_from/to_user */

device-tree mismatch: .probe never called

我的梦境 提交于 2019-12-04 04:52:28
I'm having trouble understanding how device-tree works, or specifically why this driver won't init. This is in the rockchip vendor kernel for android, version 3.10 drivers/watchdog/rk29_wdt.c (reduced for readability) static const struct of_device_id of_rk29_wdt_match[] = { { .compatible = "rockchip,watch dog" } }; static struct platform_driver rk29_wdt_driver = { .probe = rk29_wdt_probe, [..] .of_match_table = of_rk29_wdt_match, .name = "rk29-wdt", }, }; static int __init watchdog_init(void) { printk("watchdog_init\n"); return platform_driver_register(&rk29_wdt_driver); } and this is the soc

drop/rewrite/generate keyboard events under Linux

隐身守侯 提交于 2019-12-04 04:51:23
I would like to hook into, intercept, and generate keyboard (make/break) events under Linux before they get delivered to any application. More precisely, I want to detect patterns in the key event stream and be able to discard/insert events into the stream depending on the detected patterns. I've seen some related questions on SO, but: either they only deal with how to get at the key events (key loggers etc.), and not how to manipulate the propagation of them (they only listen, but don't intercept/generate). or they use passive/active grabs in X (read more on that below). A Small DSL I explain

Linux, spidev: why it shouldn't be directly in devicetree?

五迷三道 提交于 2019-12-04 04:11:44
问题 I want to define a SPI device with usermode access, as explained for example in http://linux-sunxi.org/SPIdev Following these examples, I added in the devicetree this : &ecspi1 { .... other stuff ... mydev@0 { compatible = "spidev"; spi-max-frequency = <5000000>; reg = <2>; /*chipselect*/ }; }; The platform is i.MX6. ecspi1 seems to be their SPI controller. Then I indeed get /dev/spi0.2 and /sys/class/spidev/spidev0.2 But in kernel trace there's a WARNING saying this: spidev spi0.2: buggy DT:

Spidev do not write/read simultaneously using ioctl

徘徊边缘 提交于 2019-12-04 03:47:19
I hope to find some help even if this issue might be more hardware than software related (we'll see). I'm working on a custom board based on Freescales P1021 processor (ppc, e500v2 core). A external PCB will be connected and could be configured by SPI. The specifications of this external PCB reads as it expects a 2-byte command in full duplex mode and that only the last byte is used to transfer data back on MISO. Knowing this i currently work to prepare some pieces of software to test this device. So I started with the well known spi_test program. root@p1021rdb:~# ./spi_test -D /dev

Accessing kernel driver data from FIQ interrupt handler failing

狂风中的少年 提交于 2019-12-04 03:39:16
问题 On ARM FIQ interrupts, we have some registers reserved only for FIQ use, and those are a handy way to "save the state" for example of data transfer between FIQ calls. Currently I'm triggering some GPIO pins from the FIQ, and it is working as expected. When setting up the FIQ handler, I pass the pointers to the data registers, that were mapped with ioremap. Working code looks like this: //Driver initialization: static char* dout0; static char* din0; ... static int driver_probe(struct platform

fsync, sync: does it really do what its supposed to? [closed]

一世执手 提交于 2019-12-04 03:01:59
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I would like to have more clarification on the functionality of sync(8) and fsync functions in Linux (2.6.31). Does it make sure the files are written to the respective storage? 回答1: http://linux.die.net/man/8/sync It does not make sure that files are written to respective storage. It only makes sure that cached

Device tree driven kernel for raspberry pi

ぃ、小莉子 提交于 2019-12-04 02:51:43
I'd like to boot the raspberry pi with a device-tree-driven linux kernel, is there anything special to do to do that? Can anyone point what are required to set up a device-tree-based kernel boot up for the raspberry pi. I may need to have raspberry pi kernel source where drivers for devices should be compatible with device tree. If so, where can I find such kernel sources for Raspberry Pi? m-ric Device-Tree support on Raspberry Pi Raspberry Pi embeds an ARM11 SoC: Broadcom BCM2835 . Device Tree (DT) support for ARM is fairly new, but it seems that it has made its way to the Raspberry Pi CPU.

Static functions in Linux device driver?

*爱你&永不变心* 提交于 2019-12-04 02:19:39
Is there a reason why most function definition in device driver in linux code is defined as static? Is there a reason for this? I was told this is for scoping and to prevent namespace pollution, could anyone explain it in detail why static definition is used in this context? Functions declared static are not visible outside the translation unit they are defined in (a translation unit is basically a .c file). If a function does not need to be called from outside the file, then it should be made static so as to not pollute the global namespace. This makes conflicts between names that are the

New to kernel development: “Virtual” input driver in kernel?

回眸只為那壹抹淺笑 提交于 2019-12-03 22:28:17
I'm doing some edits to an input device driver in an android kernel. This device has a limited range of keybits and evbits enabled. What I want to do is to create a new /dev/input event node that is not related to any physical device, with more keybits and evbits enabled, so that I can send real input signals from the physical driver to the userspace, in the userspace I listen to them and when received I can inject input events to the "virtual" driver writing to its event node. Does linux/android kernel offer such option? Which path should I follow? Is there any alternative to this? As a