From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Feng Kan <fkan@apm.com>
Cc: patches@apm.com, jassisinghbrar@gmail.com,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH V2 RESEND] mailbox: add ACPI support for mailbox framework
Date: Thu, 11 Jun 2015 12:59:23 +0300 [thread overview]
Message-ID: <20150611095923.GU1478@lahna.fi.intel.com> (raw)
In-Reply-To: <1428537507-30561-1-git-send-email-fkan@apm.com>
On Wed, Apr 08, 2015 at 04:58:27PM -0700, Feng Kan wrote:
> This will add support for ACPI parsing of the mboxes attribute
> when booting with ACPI table. The client will have a attribute
> mimic the dts call "mboxes". In the ACPI case, the client will
> mark "mboxes" with the ACPI reference of the mbox it wishes to
> use.
>
> Name (_DSD, Package () {
> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
> Package () {
> Package (2) {"mboxes", Package(){"^^MBOXREF, index"}}
This should be
Package (2) {"mboxes", Package() {^^MBOXREF, index}}
without quotes I think.
> }
> })
>
> Signed-off-by: Feng Kan <fkan@apm.com>
> ---
> V2 CHANGE:
> - change to use ACPI reference rather than use ACPI HID directly.
> - consolidate to use one single xlate function
> - fix code to accept use of index
>
> drivers/mailbox/mailbox.c | 105 ++++++++++++++++++++++++++-----------
> include/linux/mailbox_controller.h | 6 +--
> 2 files changed, 76 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> index 19b491d..3bb981c 100644
> --- a/drivers/mailbox/mailbox.c
> +++ b/drivers/mailbox/mailbox.c
> @@ -9,6 +9,7 @@
> * published by the Free Software Foundation.
> */
>
> +#include <linux/acpi.h>
> #include <linux/interrupt.h>
> #include <linux/spinlock.h>
> #include <linux/mutex.h>
> @@ -278,6 +279,70 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
> }
> EXPORT_SYMBOL_GPL(mbox_send_message);
>
> +#ifdef CONFIG_ACPI
> +static struct mbox_chan *mbox_acpi_parse_chan(struct device *dev, int index)
> +{
> + struct acpi_device *acpi_dev;
> + struct mbox_controller *mbox;
> + struct mbox_chan *chan;
> + int status;
> + struct acpi_reference_args args;
> +
> + status = acpi_dev_get_property_reference(ACPI_COMPANION(dev), "mboxes",
> + index, &args);
> + if (ACPI_FAILURE(status)) {
> + dev_dbg(dev, "mbox: no matching mbox found in ACPI table\n");
> + return ERR_PTR(-ENODEV);
> + }
> + acpi_dev = args.adev;
> +
> + chan = NULL;
> + list_for_each_entry(mbox, &mbox_cons, node)
> + if (ACPI_COMPANION(mbox->dev) == acpi_dev) {
> + chan = mbox->chan_xlate(mbox, args.args[0]);
> + break;
> + }
> +
> + return chan;
> +}
This looks nicer if you add
#else
static inline struct mbox_chan *mbox_acpi_parse_chan(struct device *dev, int index)
{
return NULL;
}
and then ...
> +#endif
> +
> +static struct mbox_chan *mbox_of_parse_chan(struct device *dev, int index)
> +{
> + struct of_phandle_args spec;
> + struct mbox_controller *mbox;
> + struct mbox_chan *chan;
> +
> + if (of_parse_phandle_with_args(dev->of_node, "mboxes",
> + "#mbox-cells", index, &spec)) {
> + dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__);
> + return ERR_PTR(-ENODEV);
> + }
> +
> + chan = NULL;
> + list_for_each_entry(mbox, &mbox_cons, node)
> + if (mbox->dev->of_node == spec.np) {
> + chan = mbox->chan_xlate(mbox, spec.args[0]);
> + break;
> + }
> +
> + of_node_put(spec.np);
> + return chan;
> +}
> +
> +static struct mbox_chan *mbox_parse_chan(struct device *dev, int index)
> +{
> + if (!dev)
> + return ERR_PTR(-ENODEV);
> +
> + if (dev->of_node)
> + return mbox_of_parse_chan(dev, index);
> +#ifdef CONFIG_ACPI
> + else
> + return mbox_acpi_parse_chan(dev, index);
> +#endif
.. you can get rid of the ugly #ifdef here. Just make it:
if (dev->of_node)
return mbox_of_parse_chan(dev, index);
else
return mbox_acpi_parse_chan(dev, index);
> +}
> +
prev parent reply other threads:[~2015-06-11 9:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 23:58 [PATCH V2 RESEND] mailbox: add ACPI support for mailbox framework Feng Kan
2015-04-20 21:28 ` Feng Kan
2015-04-21 7:53 ` Jassi Brar
2015-04-22 2:04 ` Rafael J. Wysocki
2015-04-29 2:52 ` Jassi Brar
2015-06-11 0:18 ` Rafael J. Wysocki
2015-06-11 9:59 ` Mika Westerberg [this message]
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=20150611095923.GU1478@lahna.fi.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=fkan@apm.com \
--cc=jassisinghbrar@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@apm.com \
--cc=rafael.j.wysocki@intel.com \
/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