Re: audio: expose real device name

2016-01-20 Thread Alexandre Ratchov
On Wed, Jan 20, 2016 at 11:50:43AM +0100, Mark Kettenis wrote:
> > Date: Wed, 20 Jan 2016 09:13:53 +0100
> > From: Alexandre Ratchov 
> > 
> > This diff makes audioctl(1) display the device name (ex. 
> > "azalia0", "cmpci0", etc) in the "name" attribute.  This way
> > audioctl(1) output could be correlated with dmesg output.  This
> > seems more useful than strings like "HD-Audio" or "CMI8338A".
> > 
> > OK?
> 
> There is a small chance that something in ports uses these strings as
> keys to store values.  This change would introduce a flag day for such
> applications, but in the long run using the driver instance name would
> help.  Except for hotplugging multiple uaudio(4) devices of course...
> 
> Anyway, I think this is ok.
> 
> But you should probably remove the ops->getdev() driver callback if
> this sticks.

Sure.  I leave this for the next time we make changes in the driver
API as they tend to be very time consuming (too many archs to
test).



audio: expose real device name

2016-01-20 Thread Alexandre Ratchov
This diff makes audioctl(1) display the device name (ex. 
"azalia0", "cmpci0", etc) in the "name" attribute.  This way
audioctl(1) output could be correlated with dmesg output.  This
seems more useful than strings like "HD-Audio" or "CMI8338A".

OK?

Index: audio.c
===
RCS file: /cvs/src/sys/dev/audio.c,v
retrieving revision 1.142
diff -u -p -u -p -r1.142 audio.c
--- audio.c 20 Jan 2016 07:59:55 -  1.142
+++ audio.c 20 Jan 2016 08:04:29 -
@@ -1584,7 +1584,11 @@ audio_ioctl(struct audio_softc *sc, unsi
error = audio_getinfo(sc, (struct audio_info *)addr);
break;
case AUDIO_GETDEV:
-   error = sc->ops->getdev(sc->arg, (audio_device_t *)addr);
+   memset(addr, 0, sizeof(struct audio_device));
+   if (sc->dev.dv_parent)
+   strlcpy(((struct audio_device *)addr)->name,
+   sc->dev.dv_parent->dv_xname,
+   MAX_AUDIO_DEV_LEN);
break;
case AUDIO_GETENC:
error = sc->ops->query_encoding(sc->arg,



Re: audio: expose real device name

2016-01-20 Thread Mark Kettenis
> Date: Wed, 20 Jan 2016 09:13:53 +0100
> From: Alexandre Ratchov 
> 
> This diff makes audioctl(1) display the device name (ex. 
> "azalia0", "cmpci0", etc) in the "name" attribute.  This way
> audioctl(1) output could be correlated with dmesg output.  This
> seems more useful than strings like "HD-Audio" or "CMI8338A".
> 
> OK?

There is a small chance that something in ports uses these strings as
keys to store values.  This change would introduce a flag day for such
applications, but in the long run using the driver instance name would
help.  Except for hotplugging multiple uaudio(4) devices of course...

Anyway, I think this is ok.

But you should probably remove the ops->getdev() driver callback if
this sticks.


> Index: audio.c
> ===
> RCS file: /cvs/src/sys/dev/audio.c,v retrieving revision 1.142 diff
> -u -p -u -p -r1.142 audio.c --- audio.c 20 Jan 2016 07:59:55 -
> 1.142 +++ audio.c 20 Jan 2016 08:04:29 - @@ -1584,7 +1584,11 @@
> audio_ioctl(struct audio_softc *sc, unsi error = audio_getinfo(sc,
> (struct audio_info *)addr); break; case AUDIO_GETDEV: - error =
> sc->ops->getdev(sc->arg, (audio_device_t *)addr); + memset(addr, 0,
> sizeof(struct audio_device)); + if (sc->dev.dv_parent) +
> strlcpy(((struct audio_device *)addr)->name, +
> sc->dev.dv_parent->dv_xname, + MAX_AUDIO_DEV_LEN); break; case
> AUDIO_GETENC: error = sc->ops->query_encoding(sc->arg,
> 
>