I spent a lot of time debugging a program today and found that the cmd parameter of the application's ioctl passed to the driver's ioctl changed. According to "Linux Device Driver", this cmd should remain unchanged. Because the ioctl function pointer in struct file_operations has been completely deleted in kernel 2.6.36 and replaced by unlocked_ioctl, I doubt whether the two are compatible. I checked some information online, and many articles only talked about it in general, saying that ioctl in the application is compatible and does not need to be changed. The biggest impact of the change of this pointer function in the driver is that inode is missing in the parameter, so the application ioctl is compatible, but our ioctl function in the driver must be changed, otherwise the cmd parameter will change:
Original driver
static const struct file_operations globalmem_fops=
{
.owner=THIS_MODULE,
.llseek=globalmem_llseek,
.open=globalmem_open,
.read=globalmem_read,
.write=globalmem_write,
.ioctl=globalmem_ioctl,
.release=globalmem_release,
};
int globalmem_ioctl(struct inode* inode,struct file* filp, unsigned int cmd, unsigned long arg)
{
switch (cmd)
{
case:XXX: ...
…
}
}
After the change
static const struct file_operations globalmem_fops=
{
.owner=THIS_MODULE,
.llseek=globalmem_llseek,
.open=globalmem_open,
.read=globalmem_read,
.write=globalmem_write,
.unlocked_ioctl=globalmem_ioctl,
.release=globalmem_release,
};
int globalmem_ioctl(struct file* filp, unsigned int cmd, unsigned long arg) //No inode parameter!
{
switch (cmd)
{
case:XXX: ...
…
}
}
Previous article:Penmount serial touch screen loading
Next article:Add your own directory to the kernel directory
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Bluetooth tester function details!
- Electric heater - "silent" transformation
- Application Development Notes | Mir MYD-YA15XC-T LoRa Wireless Communication Example
- Advanced Driver Assistance System Solution Series Introduction—Digital Camera
- Prize-winning quiz | ADI application tour - water quality and gas monitoring
- #The best content of the "Interview with famous teachers" in the Electronic Competition#The second issue - Professor Chen Nan from Xidian University
- [N32L43x Review] Unboxing and lighting
- MSP430 (F5529) UCS configuration sharing
- STM32 serial port 4 application
- Keysight Technologies DATA Center data to meet your needs ~ Download and get gifts!