Re: Replace audio(9) get_props() with duplex check in open() in partial-duplex drivers

2022-10-27 Thread Alexandre Ratchov
On Thu, Oct 27, 2022 at 08:35:31PM +, Klemens Nanni wrote: > On Thu, Oct 27, 2022 at 03:51:05PM +0200, Alexandre Ratchov wrote: > > On Thu, Oct 27, 2022 at 01:08:57PM +, Klemens Nanni wrote: > > > @@ -1040,6 +1041,9 @@ ad1848_open(void *addr, int flags) > > > > > > DPRINTF(("ad1848_open

Re: Replace audio(9) get_props() with duplex check in open() in partial-duplex drivers

2022-10-27 Thread Klemens Nanni
On Thu, Oct 27, 2022 at 03:51:05PM +0200, Alexandre Ratchov wrote: > On Thu, Oct 27, 2022 at 01:08:57PM +, Klemens Nanni wrote: > > @@ -1040,6 +1041,9 @@ ad1848_open(void *addr, int flags) > > > > DPRINTF(("ad1848_open: sc=%p\n", sc)); > > > > + if ((flags & (FWRITE | FREAD)) && sc->m

Re: Replace audio(9) get_props() with duplex check in open() in partial-duplex drivers

2022-10-27 Thread Klemens Nanni
27 Oct 2022 17:31:45 Miod Vallat : > Wait, this is wrong. All your > >     (flags & (FWRITE | FREAD)) > > comparisons must be > >     ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD)) > > in order to truly catch full-duplex opens. Otherwise the condition will > always be satisfied since one o

Re: Replace audio(9) get_props() with duplex check in open() in partial-duplex drivers

2022-10-27 Thread Alexandre Ratchov
On Thu, Oct 27, 2022 at 01:08:57PM +, Klemens Nanni wrote: > @@ -1040,6 +1041,9 @@ ad1848_open(void *addr, int flags) > > DPRINTF(("ad1848_open: sc=%p\n", sc)); > > + if ((flags & (FWRITE | FREAD)) && sc->mode != 2) > + return ENXIO; > + > sc->sc_pintr = sc->sc_p

Replace audio(9) get_props() with duplex check in open() in partial-duplex drivers

2022-10-27 Thread Klemens Nanni
Make drivers which do *not* adverise AUDIO_PROP_FULLDPLEX return ENXIO in their open() if full-duplex mode was requested. This way, sys/dev/audio.c:audio_open() will fail immediately rather than later through the to-be-removed get_props() check. This is the first round for drivers with logic in t