From: "Yu, Luming" <luming.yu@intel.com>
To: "Lennart Poettering" <mzxreary@0pointer.de>,
"Brown, Len" <len.brown@intel.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-acpi@vger.kernel.org>
Subject: RE: [PATCH 1/2] acpi,backlight: MSI S270 laptop support - ec_transaction()
Date: Mon, 14 Aug 2006 23:25:00 +0800 [thread overview]
Message-ID: <554C5F4C5BA7384EB2B412FD46A3BAD1120727@pdsmsx411.ccr.corp.intel.com> (raw)
First of all, thanks for your patch.
>+static int acpi_ec_transaction(union acpi_ec *ec, u8 command,
>+ const u8 *wdata, unsigned wdata_len,
>+ u8 *rdata, unsigned rdata_len)
I agree the name: transaction sounds better than read/write, and
can reduce redundant code from separate read, write function.
But, I guess using argument : u8 address will make the patch
looks better.
>+{
>+ if (acpi_ec_poll_mode)
>+ return acpi_ec_poll_transaction(ec, command,
>wdata, wdata_len, rdata, rdata_len);
>+ else
>+ return acpi_ec_intr_transaction(ec, command,
>wdata, wdata_len, rdata, rdata_len);
>+}
>+
It would be better to use a function pointer instead of
using if-lese statement which looks not so neat.
> static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data)
> {
>- if (acpi_ec_poll_mode)
>- return acpi_ec_poll_read(ec, address, data);
>- else
>- return acpi_ec_intr_read(ec, address, data);
>+ int result;
>+ u8 d;
>+ result = acpi_ec_transaction(ec,
>ACPI_EC_COMMAND_READ, &address, 1, &d, 1);
>+ *data = d;
>+ return result;
> }
Due to missing argument: address, you have to pass address in
argument: wdata. This kind of code style is prone to error.
> static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data)
> {
>- if (acpi_ec_poll_mode)
>- return acpi_ec_poll_write(ec, address, data);
>- else
>- return acpi_ec_intr_write(ec, address, data);
>+ u8 wdata[2] = { address, data };
>+ return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
>wdata, 2, NULL, 0);
> }
It would be more clear if there is argument : address.
>-static int acpi_ec_poll_read(union acpi_ec *ec, u8 address,
>u32 * data)
>+
>+static int acpi_ec_poll_transaction(union acpi_ec *ec, u8 command,
>+ const u8 *wdata, unsigned
>wdata_len,
>+ u8 *rdata, unsigned rdata_len)
> {
> acpi_status status = AE_OK;
> int result = 0;
> unsigned long flags = 0;
> u32 glk = 0;
>
>- ACPI_FUNCTION_TRACE("acpi_ec_read");
>+ ACPI_FUNCTION_TRACE("acpi_ec_poll_transaction");
>
>- if (!ec || !data)
>+ if (!ec || !wdata || !wdata_len || (rdata_len && !rdata))
> return_VALUE(-EINVAL);
why return -EINVAL if wdata_len == 0?
Thanks
Luming
next reply other threads:[~2006-08-14 15:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-14 15:25 Yu, Luming [this message]
2006-08-15 0:27 ` Lennart Poettering
2006-08-16 15:34 ` Len Brown
-- strict thread matches above, loose matches on Subject: below --
2006-08-10 1:05 Lennart Poettering
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=554C5F4C5BA7384EB2B412FD46A3BAD1120727@pdsmsx411.ccr.corp.intel.com \
--to=luming.yu@intel.com \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mzxreary@0pointer.de \
/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
all inboxes | Powered by JetHome®