Better names for the usb_driver struct and the init functions

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Rename snd_vendor_quirk to hiface_vendor_quirk

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Rename driver_short_name to device_short_name

The new name tells what the variable is actually used for.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Fix a checkpatch.pl warning

  WARNING: braces {} are not necessary for any arm of this statement
  #87: FILE: chip.c:83:
  +       if (quirk && quirk->device_short_name) {
  [...]
  +       } else {
  [...]

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Cosmetic cleanup of pcm.c

Group symbolic constants in the same section of the file, move types
definition before their use, align with spaces.

This makes it easier to follow the code.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Don't use explicit type names with sizeof() when allocating memory

This makes it easier to rename types and we are doing that in chip.c
too.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Don't initialize a variable when it is going to be assigned

Also make the check more explicit, hiface_pcm_playback() does return
a negative value on error.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Declare pcm_urb.buffer as u8 and remove some castings

The buffer was being casted to (void *) already when passed to
usb_fill_bulk_urb().

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Make the code in hiface_pcm_pointer() more readable

Rename "ret" to "dma_offset" and use bytes_to_frames() so that who is
going to read the code has a semantic hint of what is going on here: the
function is returning the position in the DMA buffer, expressed in
frames.

That's exactly what the documentation says; on my first review and
before this change I didn't get what the calculation in the return
statement was for exactly.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Readability improvements to hiface_pcm_playback()

Use snd_pcm_lib_buffer_bytes() to avoid calculating
(alsa_rt->buffer_size * stride) each time, but also to make it clearer
what the code is doing, the "stride" variable added some complexity that
was making it harder for me to follow the code flow.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Use the "alternate form" when printing hex values

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Add a SNDRV_PCM_HW_PARAM_RATE constraint

This is the right way to restrict the rates supported by the device.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Make format check in hiface_pcm_playback() more explicit

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Move pr_debug() at the beginning of hiface_pcm_open()

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Clarify why we iterate over the rates array in hiface_pcm_set_rate()

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>
Make the rate argument of hiface_pcm_set_rate() unsigned

Alsa considers sample rates unsigned integers.

Signed-off-by: Antonio Ospite <ao2@amarulasolutions.com>