Re: [PATCH v1] x86/platform/intel-mid: Revert "Make 'bt_sfi_data' const"

From: Ingo Molnar
Date: Thu Dec 28 2017 - 07:00:03 EST



* Julia Lawall <julia.lawall@xxxxxxx> wrote:

> > So the type is the following, in include/linux/mod_devicetable.h:
> >
> > struct x86_cpu_id {
> > __u16 vendor;
> > __u16 family;
> > __u16 model;
> > __u16 feature; /* bit index */
> > kernel_ulong_t driver_data;
> > };
> >
> > Is there a syntactic method that would allow the conversion to kernel_ulong_t, but
> > would preserve any const-ness?
> >
> > Barring that, maybe we could convert driver_data to 'void *', fix up all users,
> > and not force the type - this would allow the preservation of the const attribute,
> > I think.
> >
> > BTW., a quick grep suggests similar type casting patterns here:
> >
> > arch/x86/platform/intel-mid/pwr.c: { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PENWELL), (kernel_ulong_t)&pnw_info },
> > arch/x86/platform/intel-mid/pwr.c: { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_TANGIER), (kernel_ulong_t)&tng_info },
>
> Would it be acceptable to move the cast out of the macro to the place
> where the variable is referenced? It wouldn't help with the compiler, but
> it would be slightly easier for the human to check.

It would really be preferably to not stand in the way of the compiler here.

AFACS void * should solve the problem, and it's a kernel_ulong_t equivalent in
terms of with, right?

So let's try and solve this for real. Forcing humans to discover such things is
always a fragile concept.

Thanks,

Ingo