From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: Petr Kulhavy <petr@barix.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
devicetree@vger.kernel.org,
ALSA Development Mailing List <alsa-devel@alsa-project.org>,
Pawel Moll <pawel.moll@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
patches@opensource.wolfsonmicro.com,
Liam Girdwood <lgirdwood@gmail.com>,
Rob Herring <robh+dt@kernel.org>, Mark Brown <broonie@kernel.org>,
Kumar Gala <galak@codeaurora.org>,
Plamen Prodanov <plamen@barix.com>
Subject: Re: [PATCH v2 2/2] ASoC: wm8985: add device-tree support
Date: Mon, 23 May 2016 09:31:40 +0100 [thread overview]
Message-ID: <20160523083140.GB20422@localhost.localdomain> (raw)
In-Reply-To: <CAEP=dzB2527G27ym5pP2C1AxMKKeU7HMiYZ8_=48VBZdv6jxbw@mail.gmail.com>
On Mon, May 23, 2016 at 09:23:05AM +0200, Petr Kulhavy wrote:
> On 20 May 2016 at 18:21, Charles Keepax
> <ckeepax@opensource.wolfsonmicro.com> wrote:
> > On Tue, May 17, 2016 at 02:49:49PM +0200, Petr Kulhavy wrote:
> >> +static enum wm8985_type wm8985_data = WM8985;
> >> +static enum wm8985_type wm8758_data = WM8758;
> >> +
> >> +static const struct of_device_id wm8985_of_match[] = {
> >> + { .compatible = "wlf,wm8985", .data = &wm8985_data},
> >> + { .compatible = "wlf,wm8758", .data = &wm8758_data},
> >
> > You can probably just use (void *)WM8985 instead here.
>
> I know this pretty safe with integers but can you do this with enums?
> Doesn't it lead to undefined behaviour?
Hmm... its not uncommon that it is done in the kernel, but
that is rarely an indicator of if something is actually
technically valid or not. Casting from an integer to a pointer
is technically implementation defined, but we clearly rely on
gcc's implementation in the kernel. However, without actually
reading the spec in more detail I am unclear on if an enum counts
as an integer here, my suspicion is that it would since it
generally always implicitly casts to an int.
I guess the correct fix is that .data should probably be a
kernel_ulong_t in of_device_id. But if no one else objects I am
happy for you to leave your current code as is.
Thanks,
Charles
next prev parent reply other threads:[~2016-05-23 8:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-17 12:49 [PATCH v2 1/2] ASoC: wm8985: add device tree binding for WM8985 Petr Kulhavy
[not found] ` <1463489389-17719-1-git-send-email-petr-Qh/3xLP0EvwAvxtiuMwx3w@public.gmane.org>
2016-05-17 12:49 ` [PATCH v2 2/2] ASoC: wm8985: add device-tree support Petr Kulhavy
[not found] ` <1463489389-17719-2-git-send-email-petr-Qh/3xLP0EvwAvxtiuMwx3w@public.gmane.org>
2016-05-20 16:21 ` Charles Keepax
[not found] ` <20160520162128.GS1646-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2016-05-23 7:23 ` Petr Kulhavy
2016-05-23 8:31 ` Charles Keepax [this message]
[not found] ` <20160523083140.GB20422-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2016-05-24 8:00 ` Petr Kulhavy
2016-05-20 16:14 ` [PATCH v2 1/2] ASoC: wm8985: add device tree binding for WM8985 Charles Keepax
[not found] ` <20160520161442.GR1646-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2016-05-23 7:23 ` Petr Kulhavy
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=20160523083140.GB20422@localhost.localdomain \
--to=ckeepax@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=lgirdwood@gmail.com \
--cc=mark.rutland@arm.com \
--cc=patches@opensource.wolfsonmicro.com \
--cc=pawel.moll@arm.com \
--cc=petr@barix.com \
--cc=plamen@barix.com \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).