Re: [PATCH 2/3] net: qrtr: Define macro to convert QMI version and instance to QRTR instance

Simon Horman
2025-07-09T11:52:37Z

On Wed, Jul 09, 2025 at 07:44:49AM +0000, Yassine Oudjana wrote:
>
>
>
>
>
> Sent with Proton Mail secure email.
>
> On Monday, July 7th, 2025 at 6:06 PM, Simon Horman <horms@kernel.org> wrote:
>
> > On Sat, Jul 05, 2025 at 06:29:39PM +0000, Yassine Oudjana wrote:
> >
> > > On Wednesday, April 9th, 2025 at 3:54 PM, Konrad Dybcio konrad.dybcio@oss.qualcomm.com wrote:
> > >
> > > > On 4/6/25 4:07 PM, Yassine Oudjana wrote:
> >
> >
> > ...
> >
> > > > > diff --git a/include/linux/soc/qcom/qrtr.h b/include/linux/soc/qcom/qrtr.h
> > > > > index 4d7f25c64c56..10c89a35cbb9 100644
> > > > > --- a/include/linux/soc/qcom/qrtr.h
> > > > > +++ b/include/linux/soc/qcom/qrtr.h
> > > > > @@ -13,6 +13,8 @@ struct qrtr_device {
> > > > >
> > > > > #define to_qrtr_device(d) container_of(d, struct qrtr_device, dev)
> > > > >
> > > > > +#define QRTR_INSTANCE(qmi_version, qmi_instance) (qmi_version | qmi_instance << 8)
> > > >
> > > > Please use FIELD_PREP + GENMASK to avoid potential overflows
> > > >
> > > > Konrad
> > >
> > > Since I'm using this macro in initializing QRTR match tables I am unable to use
> > > FIELD_PREP. When I do, I get such errors:
> >
> >
> > Does using FIELD_PREP_CONST, say in a QRTR_INSTANCE_CONST variant, help?
>
> That works, but do we want to have two variants? Or in this case maybe
> I should leave qmi_interface.c untouched and define the macro only for use
> in match tables?

FWIIW, my order of preference would be:

1. Two variants, declared next to each other
2. One variant (using FIELD_PREP_CONST)
3. Leave qmi_interface.c untouched

...