Re: [PATCH] usb:serial: Add Fintek F81532/534 driver

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

 



Hi Alan,

One Thousand Gnomes 於 2016/7/29 下午 08:48 寫道:
O
+static int f81534_set_normal_register(struct usb_device *dev, u16 reg, u8 data)
+{
+	size_t count = F81534_USB_MAX_RETRY;
+	int status;
+	u8 *tmp;
+
+	tmp = kmalloc(sizeof(u8), GFP_KERNEL);
+	if (!tmp)
+		return -ENOMEM;

You end up doing huge numbers of tiny allocation and frees in some of the
code paths. I think it would be better to allocate them at a higher level
as they are not that cheap on CPU time.

+static int f81534_read_data(struct usb_serial *usbserial, u32 address,
+				size_t size, unsigned char *buf)
+{

Is a particularly good example - you do 4 mallocs plus two per byte of
data.


I'll re-factor the newest V9 patch with your suggestion. To malloc a
byte within usb_serial privates, and make a mutex to protect it.

I'll send it as V10 when I tested it.

Thanks for your suggestion.
--
With Best Regards,
Peter Hong
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" 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]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux