mouse: Do not allow unitialized driver to be loaded
Signed-off-by: Amir Hammad <amir.hammad@hotmail.com>
This commit is contained in:
parent
3003006216
commit
f8658f9411
1 changed files with 9 additions and 1 deletions
|
|
@ -56,11 +56,14 @@ static const hid_mouse_config_t *mouse_config;
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
static bool initialized = false;
|
||||
|
||||
void hid_mouse_driver_init(const hid_mouse_config_t *config)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
initialized = true;
|
||||
|
||||
mouse_config = config;
|
||||
for (i = 0; i < USBH_HID_MOUSE_MAX_DEVICES; i++) {
|
||||
mouse_device[i].state_next = STATE_INACTIVE;
|
||||
|
|
@ -73,6 +76,11 @@ void hid_mouse_driver_init(const hid_mouse_config_t *config)
|
|||
*/
|
||||
static void *init(void *usbh_dev)
|
||||
{
|
||||
if (!initialized) {
|
||||
LOG_PRINTF("\n%s/%d : driver not initialized\r\n", __FILE__, __LINE__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
hid_mouse_device_t *drvdata = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue