From: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Ji-Ze Hong (Peter Hong)" <hpeter+linux_kernel@gmail.com>
Subject: Re: [PATCH V1 3/4] usb: serial: f81534: add output pin control
Date: Thu, 21 Dec 2017 17:49:45 +0800 [thread overview]
Message-ID: <c7e9fd86-cd52-b72a-3b47-3d74323bd8a6@gmail.com> (raw)
In-Reply-To: <20171218160616.GC3374@localhost>
Hi Johan,
Johan Hovold 於 2017/12/19 上午 12:06 寫道:
> On Thu, Nov 16, 2017 at 03:46:08PM +0800, Ji-Ze Hong (Peter Hong) wrote:
>> +static int f81534_set_port_output_pin(struct usb_serial_port *port)
>> +{
>> + struct f81534_serial_private *serial_priv;
>> + struct f81534_port_private *port_priv;
>> + struct usb_serial *serial;
>> + const struct f81534_port_out_pin *pins;
>> + int status;
>> + int i;
>> + u8 value;
>> + u8 idx;
>> +
>> + serial = port->serial;
>> + serial_priv = usb_get_serial_data(serial);
>> + port_priv = usb_get_serial_port_data(port);
>> +
>> + idx = F81534_CONF_GPIO_OFFSET + port_priv->phy_num;
>> + value = serial_priv->conf_data[idx];
>> + pins = &f81534_port_out_pins[port_priv->phy_num];
>> +
>> + for (i = 0; i < ARRAY_SIZE(pins->pin); ++i) {
>> + status = f81534_set_mask_register(serial,
>> + pins->pin[i].reg_addr, pins->pin[i].reg_mask,
>> + value & BIT(i) ? pins->pin[i].reg_mask : 0);
>> + if (status)
>> + return status;
>> + }
>
> You're using 24 (get or set) accesses to update these three registers
> here. Why not read them out (if necessary), determine their new values
> and then write them back when done instead?
>
In this code, I'm only read/write 3 registers of 0x2ae8, 0x2a90, 0x2a80,
but some register will read/write more than once. Should I change the
code from port_probe() to attach() and re-write it as:
1: read the 3 register
2: change them will 12 pin desire value
3: write it back
Is it ok?
Thanks
--
With Best Regards,
Peter Hong
next prev parent reply other threads:[~2017-12-21 9:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-16 7:46 [PATCH V1 1/4] usb: serial: f81534: add high baud rate support Ji-Ze Hong (Peter Hong)
2017-11-16 7:46 ` [PATCH V1 2/4] usb: serial: f81534: add auto RTS direction support Ji-Ze Hong (Peter Hong)
2017-12-18 15:18 ` Johan Hovold
2017-11-16 7:46 ` [PATCH V1 3/4] usb: serial: f81534: add output pin control Ji-Ze Hong (Peter Hong)
2017-12-18 16:06 ` Johan Hovold
2017-12-21 9:49 ` Ji-Ze Hong (Peter Hong) [this message]
2017-12-27 10:30 ` Johan Hovold
2018-01-02 3:24 ` Ji-Ze Hong (Peter Hong)
2018-01-02 9:27 ` Johan Hovold
2017-11-16 7:46 ` [PATCH V1 4/4] usb: serial: f81534: add H/W disable port support Ji-Ze Hong (Peter Hong)
2017-12-18 16:15 ` Johan Hovold
2017-12-18 15:14 ` [PATCH V1 1/4] usb: serial: f81534: add high baud rate support Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c7e9fd86-cd52-b72a-3b47-3d74323bd8a6@gmail.com \
--to=hpeter@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpeter+linux_kernel@gmail.com \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome