From patchwork Fri Jun 26 06:46:44 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 32519 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5Q6oPQT018784 for ; Fri, 26 Jun 2009 06:50:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750887AbZFZGuV (ORCPT ); Fri, 26 Jun 2009 02:50:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750853AbZFZGuV (ORCPT ); Fri, 26 Jun 2009 02:50:21 -0400 Received: from rv-out-0506.google.com ([209.85.198.237]:51482 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750784AbZFZGuU (ORCPT ); Fri, 26 Jun 2009 02:50:20 -0400 Received: by rv-out-0506.google.com with SMTP id f6so570756rvb.1 for ; Thu, 25 Jun 2009 23:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=mPjXU2q1Gxyv/14dUgIh0IUfe+LuKCjiWsZV7kOLhF0=; b=NQYgcRmkqCaQhA2UmWn62cMoPmbAQpo3W7AtNePbyYdJdok/hASN5uK7IOysUpHjmt v6k2ztAK+Ax5ZbvaU63JHcr6SFFzyADwPFOy56XhLRx6lfJRjZFi36K+VQ9/VQD2ViPf O19wwDY4STVImeei81lecAeIBnD3MqBUjtZNI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=kgp5cycOy30CU44m3HF4BC0YUxd9nYN9Fy/l0iiFzkAJ9lwUs4qzi7Y1hayYz1OQbB qBiSnJhgfrr4vfF/u8ZOko2kGi2/ZVszRosUTPDpD1B2/lglGBY8qyif1hZm3lHlM/Bv MA798X61e1aiVh/jzrV3czdH9NtQiP7FxFzb4= Received: by 10.140.171.18 with SMTP id t18mr1985892rve.15.1245999023429; Thu, 25 Jun 2009 23:50:23 -0700 (PDT) Received: from rx1.opensource.se (mailhost.igel.co.jp [219.106.231.130]) by mx.google.com with ESMTPS id l31sm13086525rvb.23.2009.06.25.23.50.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 25 Jun 2009 23:50:22 -0700 (PDT) From: Magnus Damm To: linux-usb-devel@lists.sourceforge.net Cc: Magnus Damm , gregkh@suse.de, shimoda.yoshihiro@renesas.com, linux-sh@vger.kernel.org Date: Fri, 26 Jun 2009 15:46:44 +0900 Message-Id: <20090626064644.22542.26528.sendpatchset@rx1.opensource.se> Subject: [PATCH] usb: m66592-udc buffer management update Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From: Magnus Damm This patch updates the m66592-udc buffer management code. Use fixed buffers for bulk and isochronous pipes, also make sure to handle the isochronous-as-bulk case. With fixed buffers there is no need to keep track of used buffers with bi_bufnum. Also, this fixes a potential buffer offset problem where the base offset incorrectly varies with the number of pipes used. With this patch applied it is possible to use m66592-udc for both Ethernet and Serial using CONFIG_USB_CDC_COMPOSITE. Signed-off-by: Magnus Damm --- Tested on SH7722 Migo-R. drivers/usb/gadget/m66592-udc.c | 34 ++++++++++++---------------------- drivers/usb/gadget/m66592-udc.h | 1 - 2 files changed, 12 insertions(+), 23 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/drivers/usb/gadget/m66592-udc.c +++ work/drivers/usb/gadget/m66592-udc.c 2009-06-26 15:12:37.000000000 +0900 @@ -37,7 +37,7 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Yoshihiro Shimoda"); MODULE_ALIAS("platform:m66592_udc"); -#define DRIVER_VERSION "18 Oct 2007" +#define DRIVER_VERSION "26 Jun 2009" /* module parameters */ #if defined(CONFIG_SUPERH_BUILT_IN_M66592) @@ -276,24 +276,27 @@ static int pipe_buffer_setting(struct m6 buf_bsize = 0; break; case M66592_BULK: - bufnum = m66592->bi_bufnum + - (info->pipe - M66592_BASE_PIPENUM_BULK) * 16; - m66592->bi_bufnum += 16; + /* isochronous pipes may be used as bulk pipes */ + if (info->pipe > M66592_BASE_PIPENUM_BULK) + bufnum = info->pipe - M66592_BASE_PIPENUM_BULK; + else + bufnum = info->pipe - M66592_BASE_PIPENUM_ISOC; + + bufnum = M66592_BASE_BUFNUM + (bufnum * 16); buf_bsize = 7; pipecfg |= M66592_DBLB; if (!info->dir_in) pipecfg |= M66592_SHTNAK; break; case M66592_ISO: - bufnum = m66592->bi_bufnum + + bufnum = M66592_BASE_BUFNUM + (info->pipe - M66592_BASE_PIPENUM_ISOC) * 16; - m66592->bi_bufnum += 16; buf_bsize = 7; break; } - if (m66592->bi_bufnum > M66592_MAX_BUFNUM) { - pr_err("m66592 pipe memory is insufficient(%d)\n", - m66592->bi_bufnum); + + if (buf_bsize && ((bufnum + 16) >= M66592_MAX_BUFNUM)) { + pr_err("m66592 pipe memory is insufficient\n"); return -ENOMEM; } @@ -313,17 +316,6 @@ static void pipe_buffer_release(struct m if (info->pipe == 0) return; - switch (info->type) { - case M66592_BULK: - if (is_bulk_pipe(info->pipe)) - m66592->bi_bufnum -= 16; - break; - case M66592_ISO: - if (is_isoc_pipe(info->pipe)) - m66592->bi_bufnum -= 16; - break; - } - if (is_bulk_pipe(info->pipe)) { m66592->bulk--; } else if (is_interrupt_pipe(info->pipe)) @@ -1603,8 +1595,6 @@ static int __init m66592_probe(struct pl m66592->timer.data = (unsigned long)m66592; m66592->reg = reg; - m66592->bi_bufnum = M66592_BASE_BUFNUM; - ret = request_irq(irq, m66592_irq, IRQF_DISABLED | IRQF_SHARED, udc_name, m66592); if (ret < 0) { --- 0001/drivers/usb/gadget/m66592-udc.h +++ work/drivers/usb/gadget/m66592-udc.h 2009-06-26 15:12:14.000000000 +0900 @@ -506,7 +506,6 @@ struct m66592 { int interrupt; int isochronous; int num_dma; - int bi_bufnum; /* bulk and isochronous's bufnum */ }; #define gadget_to_m66592(_gadget) container_of(_gadget, struct m66592, gadget)