Device 'xilinx-keypad' does not have a release() function, it is broken and must be fixed.

简介

用platform_device_register()注册的设备,卸载驱动模块的时候会报下面的错误.
Device 'xilinx-keypad' does not have a release() function, it is broken and must be fixed.

原因


//https://elixir.bootlin.com/linux/v4.1/source/drivers/base/core.c

/**
 * device_release - free device structure.
 * @kobj: device's kobject.
 *
 * This is called once the reference count for the object
 * reaches 0. We forward the call to the device's release
 * method, which should handle actually freeing the structure.
 */
static void device_release(struct kobject *kobj)
{
    struct device *dev = kobj_to_dev(kobj);
    struct device_private *p = dev->p;

    /*
     * Some platform devices are driven without driver attached
     * and managed resources may have been acquired.  Make sure
     * all resources are released.
     *
     * Drivers still can add resources into device after device
     * is deleted but alive, so release devres here to avoid
     * possible memory leak.
     */
    devres_release_all(dev);

    if (dev->release)
        dev->release(dev);
    else if (dev->type && dev->type->release)
        dev->type->release(dev);
    else if (dev->class && dev->class->dev_release)
        dev->class->dev_release(dev);
    else
        WARN(1, KERN_ERR "Device '%s' does not have a release() "
            "function, it is broken and must be fixed.\n",
            dev_name(dev));
    kfree(p);
}

原因是 platform_device->device -> release 没有初始化

解决方案

使用platform_device_alloc() , platform_device_add() 替代platform_device_register()去添加设备,如果使用platform_device_register()添加设备需要自己实现 platform_device->device -> release,3.+以上的内核使用设备树管理设备,除测试外尽量少用这种代码添加的方式.

引用

https://stackoverflow.com/questions/15532170/device-has-no-release-function-what-does-this-mean
http://blog.csdn.net/x356982611/article/details/79399371

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
An LCD (Liquid Crystal Display) is a type of display technology that uses liquid crystals to display information. LCDs are commonly used in electronic devices such as digital watches, calculators, and mobile phones, and can also be used in more complex systems such as embedded systems and microcontrollers. A matrix keypad, on the other hand, is a type of input device that allows users to input data through a combination of buttons arranged in a matrix pattern. A typical matrix keypad has rows and columns of buttons that can be pressed to input data. The arrangement of the buttons in a matrix pattern allows for a large number of buttons to be accommodated in a small space. To interface an LCD and a matrix keypad with a microcontroller, several specifications need to be considered. These include: 1. Pinout: The pinout of the LCD and matrix keypad needs to be understood in order to connect them to the microcontroller. The pinout typically includes pins for power, ground, data, and control signals. 2. Voltage levels: The voltage levels of the LCD and matrix keypad need to be compatible with the microcontroller. Most microcontrollers operate at 5V or 3.3V, so the LCD and matrix keypad should also operate at these voltage levels. 3. Data communication protocol: The data communication protocol between the microcontroller, LCD, and matrix keypad needs to be understood in order to transfer data between them. The most common data communication protocols used are SPI (Serial Peripheral Interface) and I2C (Inter-Integrated Circuit). 4. LCD commands: The LCD has a set of commands that can be used to control its behavior, such as clearing the screen, setting the cursor position, and displaying text. These commands need to be understood in order to control the LCD using the microcontroller. 5. Matrix keypad scanning: The matrix keypad needs to be scanned in order to detect which buttons are being pressed. This is typically done using a technique called matrix scanning, where the rows and columns of the keypad are scanned sequentially to detect button presses. Overall, interfacing an LCD and matrix keypad with a microcontroller requires a thorough understanding of their specifications and how they can be connected and controlled.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值