Message ID | 1571295929-47286-17-git-send-email-biju.das@bp.renesas.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | Audio improvements/SSIU BUSIF/ | expand |
Hi! > --- a/include/sound/soc-dpcm.h > +++ b/include/sound/soc-dpcm.h > @@ -103,6 +103,9 @@ struct snd_soc_dpcm_runtime { > int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */ > }; > > +#define for_each_dpcm_fe(be, stream, dpcm) \ > + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) > + This macro is really confusing. dpcm is used as both control variable of the loop and name of the field in *be. Plus it relies on list_fe variable to be present in the context including it... that's non-standard. Oh and "&(be)->" can be written as "(be)." AFAICT. Best regards, Pavel
+ Morimoto-San, > Subject: Re: [PATCH 4.19.y-cip 16/57] ASoC: add for_each_dpcm_fe() macro > > Hi! > > > --- a/include/sound/soc-dpcm.h > > +++ b/include/sound/soc-dpcm.h > > @@ -103,6 +103,9 @@ struct snd_soc_dpcm_runtime { > > int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */ }; > > > > +#define for_each_dpcm_fe(be, stream, dpcm) > \ > > + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) > > + > > This macro is really confusing. dpcm is used as both control variable of the > loop and name of the field in *be. Plus it relies on list_fe variable to be > present in the context including it... that's non-standard. > > Oh and "&(be)->" can be written as "(be)." AFAICT. Morimoto-San, Do you have any opinion on Pavel's findings? Regards, Biju
Hi > > > --- a/include/sound/soc-dpcm.h > > > +++ b/include/sound/soc-dpcm.h > > > @@ -103,6 +103,9 @@ struct snd_soc_dpcm_runtime { > > > int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */ }; > > > > > > +#define for_each_dpcm_fe(be, stream, dpcm) > > \ > > > + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) > > > + > > > > This macro is really confusing. dpcm is used as both control variable of the > > loop and name of the field in *be. Ohh, yes, indeed. Thank you for pointing it. I will post fixup patch > Plus it relies on list_fe variable to be > > present in the context including it... that's non-standard. sorry I couldn't understand about this > > Oh and "&(be)->" can be written as "(be)." AFAICT. This "&" is for fe_clients Thank you for your help !! Best regards --- Kuninori Morimoto
On Wed 2019-10-23 10:28:36, Kuninori Morimoto wrote: > > Hi > > > > > --- a/include/sound/soc-dpcm.h > > > > +++ b/include/sound/soc-dpcm.h > > > > @@ -103,6 +103,9 @@ struct snd_soc_dpcm_runtime { > > > > int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */ }; > > > > > > > > +#define for_each_dpcm_fe(be, stream, dpcm) > > > \ > > > > + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) > > > > + > > > > > > This macro is really confusing. dpcm is used as both control variable of the > > > loop and name of the field in *be. > > Ohh, yes, indeed. > Thank you for pointing it. I will post fixup patch Thanks! > > Plus it relies on list_fe variable to be > > > present in the context including it... that's non-standard. > > sorry I couldn't understand about this Macro is: > +#define for_each_dpcm_fe(be, stream, dpcm) \ > + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) It should be: > +#define for_each_dpcm_fe(be, stream, dpcm, list_de) \ > + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) [accessing variables not passed as macro arguments is strange/surprising]. > > > Oh and "&(be)->" can be written as "(be)." AFAICT. > > This "&" is for fe_clients Aha, sorry, I misparsed that one. Pavel
Hi Pavel > > +#define for_each_dpcm_fe(be, stream, dpcm) \ > > + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) > > It should be: > > > +#define for_each_dpcm_fe(be, stream, dpcm, list_de) \ > > + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) > > [accessing variables not passed as macro arguments is strange/surprising]. Ahh, OK. But, I would say, Yes and No. Indeed, using not passed parameter in macro is strange. But, this time, it is used at list_for_each_entry(). Last one is struct location/member, not parameter. In this case, in order to use properly, macro name is indicating "for what". We have xx_fe and xx_be. #define for_each_dpcm_fe(be, stream, _dpcm) \ list_for_each_entry(_dpcm, &(be)->dpcm[stream].fe_clients, list_fe) #define for_each_dpcm_be(fe, stream, _dpcm) \ list_for_each_entry(_dpcm, &(fe)->dpcm[stream].be_clients, list_be) Thank you for your help !! Best regards --- Kuninori Morimoto
diff --git a/include/sound/soc-dpcm.h b/include/sound/soc-dpcm.h index 9bb92f1..f130de6 100644 --- a/include/sound/soc-dpcm.h +++ b/include/sound/soc-dpcm.h @@ -103,6 +103,9 @@ struct snd_soc_dpcm_runtime { int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */ }; +#define for_each_dpcm_fe(be, stream, dpcm) \ + list_for_each_entry(dpcm, &(be)->dpcm[stream].fe_clients, list_fe) + /* can this BE stop and free */ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, struct snd_soc_pcm_runtime *be, int stream); diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 06eedb5..14132f6 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1255,7 +1255,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, be_substream = snd_soc_dpcm_get_substream(be, stream); - list_for_each_entry(dpcm, &be->dpcm[stream].fe_clients, list_fe) { + for_each_dpcm_fe(be, stream, dpcm) { if (dpcm->fe == fe) continue; @@ -3223,7 +3223,7 @@ int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, struct snd_soc_dpcm *dpcm; int state; - list_for_each_entry(dpcm, &be->dpcm[stream].fe_clients, list_fe) { + for_each_dpcm_fe(be, stream, dpcm) { if (dpcm->fe == fe) continue; @@ -3250,7 +3250,7 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, struct snd_soc_dpcm *dpcm; int state; - list_for_each_entry(dpcm, &be->dpcm[stream].fe_clients, list_fe) { + for_each_dpcm_fe(be, stream, dpcm) { if (dpcm->fe == fe) continue;