From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753296AbbCNMCt (ORCPT ); Sat, 14 Mar 2015 08:02:49 -0400 Received: from mail-lb0-f171.google.com ([209.85.217.171]:33538 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbbCNMCq (ORCPT ); Sat, 14 Mar 2015 08:02:46 -0400 Date: Sat, 14 Mar 2015 13:02:31 +0100 From: Johan Hovold To: Peter Hung Cc: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, tom_tsai@fintek.com.tw, peter_hong@fintek.com.tw, Peter Hung Subject: Re: [PATCH V8 04/10] USB: f81232: implement read IIR/MSR with endpoint Message-ID: <20150314120231.GD9442@localhost> References: <1424944936-7117-1-git-send-email-hpeter+linux_kernel@gmail.com> <1424944936-7117-5-git-send-email-hpeter+linux_kernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424944936-7117-5-git-send-email-hpeter+linux_kernel@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 26, 2015 at 06:02:10PM +0800, Peter Hung wrote: > The interrupt endpoint will report current IIR. If we got IIR with MSR changed > , We will do read MSR with interrupt_work worker to do f81232_read_msr() > function. > > Signed-off-by: Peter Hung > --- > drivers/usb/serial/f81232.c | 126 +++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 118 insertions(+), 8 deletions(-) > > diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c > index cf5b902..46a81ef 100644 > --- a/drivers/usb/serial/f81232.c > +++ b/drivers/usb/serial/f81232.c > @@ -31,6 +31,13 @@ static const struct usb_device_id id_table[] = { > }; > MODULE_DEVICE_TABLE(usb, id_table); > > +/* USB Control EP parameter */ > +#define F81232_REGISTER_REQUEST 0xa0 > +#define F81232_GET_REGISTER 0xc0 > + > +#define SERIAL_BASE_ADDRESS 0x0120 > +#define MODEM_STATUS_REGISTER (0x06 + SERIAL_BASE_ADDRESS) Could you indent the values using two tabs so the INTERRUPT_ENABLE_REGISTER in a following patch will also fit? > + > #define CONTROL_DTR 0x01 > #define CONTROL_RTS 0x02 > > @@ -49,19 +56,112 @@ struct f81232_private { > struct mutex lock; > u8 line_control; > u8 modem_status; > + struct work_struct interrupt_work; > + struct usb_serial_port *port; > }; > > +static int f81232_get_register(struct usb_serial_port *port, u16 reg, u8 *val) > +{ > + int status; > + u8 *tmp; > + struct usb_device *dev = port->serial->dev; > + > + tmp = kmalloc(sizeof(*val), GFP_KERNEL); > + if (!tmp) > + return -ENOMEM; > + > + status = usb_control_msg(dev, > + usb_rcvctrlpipe(dev, 0), > + F81232_REGISTER_REQUEST, > + F81232_GET_REGISTER, > + reg, > + 0, > + tmp, > + sizeof(u8), Please use sizeof(*val) here as well for consistency, > + USB_CTRL_GET_TIMEOUT); > + if (status != sizeof(*val)) { > + dev_err(&port->dev, "%s failed status: %d\n", __func__, status); > + > + if (status == 0) > + status = -EIO; > + else > + status = usb_translate_errors(status); Could you rewrite this as if (status < 0) status = usb_translate_errors(status); else status = 0; > + } else { > + status = 0; > + *val = *tmp; > + } > + > + kfree(tmp); > + return status; > +} Same comments apply to set_register in a follow up patch. Looks good otherwise, Johan