From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752193AbcG2Msb (ORCPT ); Fri, 29 Jul 2016 08:48:31 -0400 Received: from lxorguk.ukuu.org.uk ([81.2.110.251]:33016 "EHLO lxorguk.ukuu.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751329AbcG2Ms3 (ORCPT ); Fri, 29 Jul 2016 08:48:29 -0400 Date: Fri, 29 Jul 2016 13:48:02 +0100 From: One Thousand Gnomes To: "Ji-Ze Hong (Peter Hong)" Cc: johan@kernel.org, gregkh@linuxfoundation.org, tom_tsai@fintek.com.tw, peter_hong@fintek.com.tw, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Ji-Ze Hong (Peter Hong)" Subject: Re: [PATCH] usb:serial: Add Fintek F81532/534 driver Message-ID: <20160729134802.3bdbfe84@lxorguk.ukuu.org.uk> In-Reply-To: <1464658417-2689-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1464658417-2689-1-git-send-email-hpeter+linux_kernel@gmail.com> Organization: Intel Corporation X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Alan