Re: Interacting with a input kernel driver from user space

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

 



Why? I thought this thing is an input device? Why does an application have to modify a running device? Is this modification local to the application<->device interface or does it also affect all other running applications that use this device? If it is a configuration value to put the device into a different state or similar, then you can use a sysfs attribute. The user can change this with "echo <value> >/sys/class/input/inputX/<attribute>"

I'm already with working examples of ATTRIB in my driver project. The thing is that I have random kernel panics when I try to read from the attribute. This is my attribute code:

static ssize_t usbtouchscreen_get_state(struct device *dev, struct device_attribute *attr, char *buf)
{
    int count=0;
    struct usbtouch_usb *usbtouch = dev_get_drvdata(dev);
    struct dpx_priv *priv = usbtouch->priv;

printk(KERN_INFO "state length: %d",sizeof(DPX_DEVICE_STATE)); // size = 43196 bytes

    memcpy(buf,(void*)&priv->context->State,sizeof(DPX_DEVICE_STATE));

    return sizeof(DPX_DEVICE_STATE);
}

static DEVICE_ATTR(state, 0777, usbtouchscreen_get_state, NULL);

Should I make anykind of protection while doing this operation? I have read in some answer from you guys, that I should create an attribute for every field of the structure I want to bring to userspace, but that will make me have tenths of attributes. The problem for me are not the number of attributes, but the changes I will need to have in my control panel to support that architecture. One attribute with the content of State variable would be perfect.

Any ideas?

Thanks,

Nuno

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux