Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5014186d authored by Dmitry Torokhov's avatar Dmitry Torokhov
Browse files

Input: USB devices - handle errors when registering input devices



Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent db61a912
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
	struct usb_acecad *acecad;
	struct input_dev *input_dev;
	int pipe, maxp;
	int err = -ENOMEM;

	if (interface->desc.bNumEndpoints != 1)
		return -ENODEV;
@@ -149,16 +150,22 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_

	acecad = kzalloc(sizeof(struct usb_acecad), GFP_KERNEL);
	input_dev = input_allocate_device();
	if (!acecad || !input_dev)
	if (!acecad || !input_dev) {
		err = -ENOMEM;
		goto fail1;
	}

	acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma);
	if (!acecad->data)
	if (!acecad->data) {
		err= -ENOMEM;
		goto fail1;
	}

	acecad->irq = usb_alloc_urb(0, GFP_KERNEL);
	if (!acecad->irq)
	if (!acecad->irq) {
		err = -ENOMEM;
		goto fail2;
	}

	acecad->usbdev = dev;
	acecad->input = input_dev;
@@ -221,7 +228,9 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
	acecad->irq->transfer_dma = acecad->data_dma;
	acecad->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;

	input_register_device(acecad->input);
	err = input_register_device(acecad->input);
	if (err)
		goto fail2;

	usb_set_intfdata(intf, acecad);

@@ -230,7 +239,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
 fail2:	usb_buffer_free(dev, 8, acecad->data, acecad->data_dma);
 fail1: input_free_device(input_dev);
	kfree(acecad);
	return -ENOMEM;
	return err;
}

static void usb_acecad_disconnect(struct usb_interface *intf)
+14 −14
Original line number Diff line number Diff line
@@ -1972,6 +1972,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
		AIPTEK_PROGRAMMABLE_DELAY_200,
		AIPTEK_PROGRAMMABLE_DELAY_300
	};
	int err = -ENOMEM;

	/* programmableDelay is where the command-line specified
	 * delay is kept. We make it the first element of speeds[],
@@ -2133,7 +2134,9 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)

	/* Register the tablet as an Input Device
	 */
	input_register_device(aiptek->inputdev);
	err = input_register_device(aiptek->inputdev);
	if (err)
		goto fail2;

	/* We now will look for the evdev device which is mapped to
	 * the tablet. The partial name is kept in the link list of
@@ -2169,19 +2172,9 @@ fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
			aiptek->data_dma);
 fail1:	input_free_device(inputdev);
	kfree(aiptek);
	return -ENOMEM;
	return err;
}

/* Forward declaration */
static void aiptek_disconnect(struct usb_interface *intf);

static struct usb_driver aiptek_driver = {
	.name = "aiptek",
	.probe = aiptek_probe,
	.disconnect = aiptek_disconnect,
	.id_table = aiptek_ids,
};

/***********************************************************************
 * Deal with tablet disconnecting from the system.
 */
@@ -2206,6 +2199,13 @@ static void aiptek_disconnect(struct usb_interface *intf)
	}
}

static struct usb_driver aiptek_driver = {
	.name = "aiptek",
	.probe = aiptek_probe,
	.disconnect = aiptek_disconnect,
	.id_table = aiptek_ids,
};

static int __init aiptek_init(void)
{
	int result = usb_register(&aiptek_driver);
+10 −10
Original line number Diff line number Diff line
@@ -491,8 +491,7 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
	struct usb_host_interface *iface_desc;
	struct usb_endpoint_descriptor *endpoint;
	int int_in_endpointAddr = 0;
	int i, retval = -ENOMEM;

	int i, error = -ENOMEM;

	/* set up the endpoint information */
	/* use only the first interrupt-in endpoint */
@@ -567,17 +566,13 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
	}

	dev->urb = usb_alloc_urb(0, GFP_KERNEL);
	if (!dev->urb) {
		retval = -ENOMEM;
	if (!dev->urb)
		goto err_free_devs;
	}

	dev->data = usb_buffer_alloc(dev->udev, dev->datalen, GFP_KERNEL,
				     &dev->urb->transfer_dma);
	if (!dev->data) {
		retval = -ENOMEM;
	if (!dev->data)
		goto err_free_urb;
	}

	usb_fill_int_urb(dev->urb, udev,
			 usb_rcvintpipe(udev, int_in_endpointAddr),
@@ -633,20 +628,25 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
	set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
	set_bit(BTN_LEFT, input_dev->keybit);

	input_register_device(dev->input);
	error = input_register_device(dev->input);
	if (error)
		goto err_free_buffer;

	/* save our data pointer in this interface device */
	usb_set_intfdata(iface, dev);

	return 0;

 err_free_buffer:
	usb_buffer_free(dev->udev, dev->datalen,
			dev->data, dev->urb->transfer_dma);
 err_free_urb:
	usb_free_urb(dev->urb);
 err_free_devs:
	usb_set_intfdata(iface, NULL);
	kfree(dev);
	input_free_device(input_dev);
	return retval;
	return error;
}

static void atp_disconnect(struct usb_interface *iface)
+6 −4
Original line number Diff line number Diff line
@@ -772,7 +772,9 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de
		goto fail3;

	/* Set up and register input device */
	input_register_device(ati_remote->idev);
	err = input_register_device(ati_remote->idev);
	if (err)
		goto fail3;

	usb_set_intfdata(interface, ati_remote);
	return 0;
+4 −4
Original line number Diff line number Diff line
@@ -337,7 +337,7 @@ static void ati_remote2_complete_key(struct urb *urb)
static int ati_remote2_input_init(struct ati_remote2 *ar2)
{
	struct input_dev *idev;
	int i;
	int i, retval;

	idev = input_allocate_device();
	if (!idev)
@@ -364,11 +364,11 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2)
	usb_to_input_id(ar2->udev, &idev->id);
	idev->cdev.dev = &ar2->udev->dev;

	i = input_register_device(idev);
	if (i)
	retval = input_register_device(idev);
	if (retval)
		input_free_device(idev);

	return i;
	return retval;
}

static int ati_remote2_urb_init(struct ati_remote2 *ar2)
Loading