From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Ricardo Neri <ricardo.neri@ti.com>
Cc: peter.ujfalusi@ti.com, s-guiriec@ti.com, b-cousson@ti.com,
linux-omap@vger.kernel.org
Subject: Re: [PATCH v2 7/7] OMAPDSS: HDMI: Create platform device for audio support
Date: Mon, 5 Nov 2012 10:46:15 +0200 [thread overview]
Message-ID: <50977CD7.7070609@ti.com> (raw)
In-Reply-To: <1351902708-866-8-git-send-email-ricardo.neri@ti.com>
[-- Attachment #1: Type: text/plain, Size: 3108 bytes --]
On 2012-11-03 02:31, Ricardo Neri wrote:
> Creating the accessory devices, such as audio, from the HDMI driver
> allows to regard HDMI as a single entity with audio an display
> functionality. This intends to follow the design of drivers such
> as MFD, in which a single entity handles the creation of the accessory
> devices. Such devices are then used by domain-specific drivers; audio in
> this case.
>
> Also, this is in line with the DT implementation of HDMI, in which we will
> have a single node to describe this feature of the OMAP SoC.
>
> Signed-off-by: Ricardo Neri <ricardo.neri@ti.com>
> ---
> drivers/video/omap2/dss/hdmi.c | 62 ++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 62 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
> index 4adf830..d6ce4c6 100644
> --- a/drivers/video/omap2/dss/hdmi.c
> +++ b/drivers/video/omap2/dss/hdmi.c
> @@ -60,6 +60,9 @@
> static struct {
> struct mutex lock;
> struct platform_device *pdev;
> +#if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
> + struct platform_device *audio_pdev;
> +#endif
>
> struct hdmi_ip_data ip_data;
>
> @@ -766,6 +769,54 @@ static void hdmi_put_clocks(void)
> }
>
> #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
> +static int hdmi_probe_audio(struct platform_device *pdev)
> +{
> + struct resource *res;
> + u32 port_offset, port_size;
> + struct resource aud_res[2] = {
> + DEFINE_RES_MEM(-1, -1),
> + DEFINE_RES_DMA(-1),
> + };
> +
> + hdmi.audio_pdev = ERR_PTR(-EINVAL);
I don't like this. I think ERR_PTR stuff should be used only for return
values, not when storing pointers. I think it's much more natural and
less error prone to do if (hdmi.audio_pdev == NULL) than if
(IS_ERR(hdmi.audio_pdev)).
So store the return value from platform_dev_register first to a local
variable, check IS_ERR for that, and only then store it to hdmi.audio_pdev.
> + res = platform_get_resource(hdmi.pdev, IORESOURCE_MEM, 0);
> + if (!res) {
> + DSSERR("can't get IORESOURCE_MEM HDMI\n");
> + return -EINVAL;
> + }
> +
> + /*
> + * Pass DMA audio port to audio drivers.
> + * Audio drivers should not ioremap it.
> + */
> + hdmi.ip_data.ops->audio_get_dma_port(&port_offset, &port_size);
> +
> + aud_res[0].start = res->start + port_offset;
> + aud_res[0].end = aud_res[0].start + port_size - 1;
> +
> + res = platform_get_resource(hdmi.pdev, IORESOURCE_DMA, 0);
> + if (!res) {
> + DSSERR("can't get IORESOURCE_DMA HDMI\n");
> + return -EINVAL;
> + }
> +
> + /* Pass the audio DMA request resource to audio drivers. */
> + aud_res[1].start = res->start;
> +
> + /* create platform device for HDMI audio driver */
> + hdmi.audio_pdev = platform_device_register_simple(
> + "omap_hdmi_audio",
> + -1, aud_res,
> + ARRAY_SIZE(aud_res));
Not a problem for the time being, but the above prevents us from having
two HDMI outputs. Perhaps you could use hdmi pdev's ID instead of -1 above?
Otherwise I think the series is ok.
Tomi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 897 bytes --]
next prev parent reply other threads:[~2012-11-05 8:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-03 0:31 [PATCH v2 0/7] Create platform device for audio support Ricardo Neri
2012-11-03 0:31 ` [PATCH v2 1/7] OMAPDSS: HDMI: Rename resource variable at probe Ricardo Neri
2012-11-03 0:31 ` [PATCH v2 2/7] OMAPDSS: HDMI: Convert to devm_request_and_ioremap Ricardo Neri
2012-11-03 0:31 ` [PATCH v2 3/7] OMAPDSS: HDMI: Make panel return dssdev register errors Ricardo Neri
2012-11-03 0:31 ` [PATCH v2 4/7] OMAPDSS: HDMI: Handle panel init error at probe Ricardo Neri
2012-11-03 0:31 ` [PATCH v2 5/7] OMAPDSS: HDMI: Uninit display on device add error Ricardo Neri
2012-11-03 0:31 ` [PATCH v2 6/7] OMAPDSS: HDMI: Add op to get audio DMA port address offset Ricardo Neri
2012-11-03 0:31 ` [PATCH v2 7/7] OMAPDSS: HDMI: Create platform device for audio support Ricardo Neri
2012-11-05 8:46 ` Tomi Valkeinen [this message]
2012-11-06 5:27 ` Ricardo Neri
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=50977CD7.7070609@ti.com \
--to=tomi.valkeinen@ti.com \
--cc=b-cousson@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=peter.ujfalusi@ti.com \
--cc=ricardo.neri@ti.com \
--cc=s-guiriec@ti.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;
as well as URLs for NNTP newsgroup(s).