From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Keepax Subject: Re: [PATCH v2 2/2] ASoC: wm8985: add device-tree support Date: Mon, 23 May 2016 09:31:40 +0100 Message-ID: <20160523083140.GB20422@localhost.localdomain> References: <1463489389-17719-1-git-send-email-petr@barix.com> <1463489389-17719-2-git-send-email-petr@barix.com> <20160520162128.GS1646@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Petr Kulhavy Cc: Mark Rutland , devicetree@vger.kernel.org, ALSA Development Mailing List , Pawel Moll , Ian Campbell , patches@opensource.wolfsonmicro.com, Liam Girdwood , Rob Herring , Mark Brown , Kumar Gala , Plamen Prodanov List-Id: devicetree@vger.kernel.org On Mon, May 23, 2016 at 09:23:05AM +0200, Petr Kulhavy wrote: > On 20 May 2016 at 18:21, Charles Keepax > 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