History log of /linux-master/sound/drivers/mpu401/mpu401_uart.c
Revision Date Author Comments
# d2bc4d9a 08-Jun-2021 Takashi Iwai <tiwai@suse.de>

ALSA: mpu401: Fix assignment in if condition

MPU401 driver code contains a few assignments in if condition, which
is a bad coding style that may confuse readers and occasionally lead
to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-60-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1a59d1b8 27-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version this program is distributed in the
hope that it will be useful but without any warranty without even
the implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details you
should have received a copy of the gnu general public license along
with this program if not write to the free software foundation inc
59 temple place suite 330 boston ma 02111 1307 usa

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 1334 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 969686ee 03-Aug-2018 Takashi Iwai <tiwai@suse.de>

ALSA: drivers: Remove empty init and exit

For a sake of code simplification, remove the init and the exit
entries that do nothing.

Notes for readers: actually it's OK to remove *both* init and exit,
but not OK to remove the exit entry. By removing only the exit while
keeping init, the module becomes permanently loaded; i.e. you cannot
unload it any longer!

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# bc47ba90 24-Oct-2017 Kees Cook <keescook@chromium.org>

ALSA: drivers: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f1a77dc1 12-Aug-2017 Markus Elfring <elfring@users.sourceforge.net>

ALSA: mpu401: Adjust four checks for null pointers

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ec1f43c8 12-Aug-2017 Markus Elfring <elfring@users.sourceforge.net>

ALSA: mpu401: Use common error handling code in snd_mpu401_uart_new()

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 30b2aeb8 12-Aug-2017 Markus Elfring <elfring@users.sourceforge.net>

ALSA: mpu401: Delete an error message for a failed memory allocation in snd_mpu401_uart_new()

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c36f486d 05-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: drivers: Constify snd_rawmidi_ops

Now snd_rawmidi_ops is maintained as a const pointer in snd_rawmidi,
we can constify the definitions.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6cbbfe1c 28-Jan-2015 Takashi Iwai <tiwai@suse.de>

ALSA: Include linux/io.h instead of asm/io.h

Nowadays it's recommended. Replace all in a shot.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b093ed23 19-Jan-2015 Takashi Iwai <tiwai@suse.de>

ALSA: mpu401: Use setup_timer() and mod_timer()

No functional change, refactoring with the standard helpers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# eb7c06e8 11-Mar-2013 Yacine Belkadi <yacine.belkadi.1@gmail.com>

ALSA: add/change some comments describing function return values

script/kernel-doc reports the following type of warnings (when run in verbose
mode):

Warning(sound/core/init.c:152): No description found for return value of
'snd_card_create'

To fix that:
- add missing descriptions of function return values
- use "Return:" sections to describe those return values

Along the way:
- complete some descriptions
- fix some typos

Signed-off-by: Yacine Belkadi <yacine.belkadi.1@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# bc733d49 23-Jul-2012 Takashi Iwai <tiwai@suse.de>

ALSA: mpu401: Fix missing initialization of irq field

The irq field of struct snd_mpu401 is supposed to be initialized to -1.
Since it's set to zero as of now, a probing error before the irq
installation results in a kernel warning "Trying to free already-free
IRQ 0".

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=44821
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# da155d5b 14-Jul-2011 Paul Gortmaker <paul.gortmaker@windriver.com>

sound: Add module.h to the previously silent sound users

Lots of sound drivers were getting module.h via the implicit presence
of it in <linux/device.h> but we are going to clean that up. So
fix up those users now.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>


# 88e24c3a 22-Sep-2011 Yong Zhang <yong.zhang0@gmail.com>

sound: irq: Remove IRQF_DISABLED

Since commit [e58aa3d2: genirq: Run irq handlers with interrupts disabled],
We run all interrupt handlers with interrupts disabled
and we even check and yell when an interrupt handler
returns with interrupts enabled (see commit [b738a50a:
genirq: Warn when handler enables interrupts]).

So now this flag is a NOOP and can be removed.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# dba8b469 13-Sep-2011 Clemens Ladisch <clemens@ladisch.de>

ALSA: mpu401: clean up interrupt specification

The semantics of snd_mpu401_uart_new()'s interrupt parameters are
somewhat counterintuitive: To prevent the function from allocating its
own interrupt, either the irq number must be invalid, or the irq_flags
parameter must be zero. At the same time, the irq parameter being
invalid specifies that the mpu401 code has to work without an interrupt
allocated by the caller. This implies that, if there is an interrupt
and it is allocated by the caller, the irq parameter must be set to
a valid-looking number which then isn't actually used.

With the removal of IRQF_DISABLED, zero becomes a valid irq_flags value,
which forces us to handle the parameters differently.

This patch introduces a new flag MPU401_INFO_IRQ_HOOK for when the
device interrupt is handled by the caller, and makes the allocation of
the interrupt to depend only on the irq parameter. As suggested by
Takashi, the irq_flags parameter was dropped because, when used, it had
the constant value IRQF_DISABLED.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# df7e3fdf 25-Apr-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] Add MPU401_INFO_NO_ACK bitflag

Added MPU401_INFO_NO_ACK bitflag to ignore the ACK check for UART
commands. VT172x doesn't handle ACK commands, for example.

Tested-by: Pavel Hofman <pavel.hofman@insite.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b415ed45 23-Apr-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] Define MPU401 registers in sound/mpu401_uart.h

Define some MPU401 registers in sound/mpu401_uart.h so that other
drivers can refer to them.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ea6b5828 25-Feb-2008 Clemens Ladisch <clemens@ladisch.de>

[ALSA] mpu401: reduce tx loop timeout

Reduce the number of times to check for a non-empty Tx FIFO from 100 to
2 because there is no MPU-401 implementation that needs more than one or
two reads to determine the actual FIFO status.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>


# 9004acc7 08-Jan-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] Remove sound/driver.h

This header file exists only for some hacks to adapt alsa-driver
tree. It's useless for building in the kernel. Let's move a few
lines in it to sound/core.h and remove it.
With this patch, sound/driver.h isn't removed but has just a single
compile warning to include it. This should be really killed in
future.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 60fac85f 12-Nov-2007 Clemens Ladisch <clemens@ladisch.de>

[ALSA] mpu401: fix recursive locking in timer

When the output and input ports are used at the same time, the timer can
be interrupted by the hardware interrupt, so we have to disable
interrupts when we take a lock in the timer.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# c1017a4c 15-Oct-2007 Jaroslav Kysela <perex@perex.cz>

[ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz


Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# c1099fcb 11-Oct-2007 Clemens Ladisch <clemens@ladisch.de>

[ALSA] mpu-401: remove MPU401_INFO_UART_ONLY flag

Since the last patch made the ENTER_UART command optional, the
enter_uart option and its corresponding flag have become superfluous.
The uart_enter option remains for backward compatibility but just prints
a warning when used.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 69d8d3eb 11-Oct-2007 Clemens Ladisch <clemens@ladisch.de>

[ALSA] mpu-401: do not require an ACK byte for the ENTER_UART command

The original MPU-401 does not send an ACK byte after processing the
ENTER_UART command, so we better do not try to wait for it.
Many clones get this wrong and do send an ACK, but when interpreting it
as MIDI, it is just a harmless Active Sensing message, and it is likely
to be read and discarded by the interrupt handler before the MIDI input
device is triggered.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 8f7ba051 22-Feb-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] mpu401 - Add MPU401_INFO_UART_ONLY bitflag

Added MPU401_INFO_UART_ONLY bitflag to avoid issueing UART_ENTER command
at opening streams. Some devices support only UART mode and give errors
to UART_ENTER.
A new module option, uart_enter, is added to snd-mpu401 driver.
For UART-only devices, set uart_enter=0.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 7d12e780 05-Oct-2006 David Howells <dhowells@redhat.com>

IRQ: Maintain regs pointer globally rather than passing to IRQ handlers

Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.

The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).

Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.

Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.

I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.

This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

struct pt_regs *old_regs = set_irq_regs(regs);

And put the old one back at the end:

set_irq_regs(old_regs);

Don't pass regs through to generic_handle_irq() or __do_IRQ().

In timer_interrupt(), this sort of change will be necessary:

- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);

I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().

Some notes on the interrupt handling in the drivers:

(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.

(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.

(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.

Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)


# 302e4c2f 23-May-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] Change an arugment of snd_mpu401_uart_new() to bit flags

Change the 5th argument of snd_mpu401_uart_new() to bit flags
instead of a boolean. The argument takes bits that consist of
MPU401_INFO_XXX flags.
The callers that used the value 1 there are replaced with
MPU401_INFO_INTEGRATED.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2851d963 18-May-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] mpu401_uart - Fix coding style and code clean up

- fold lines and fix spaces to follow the standard style
- added some comments
- moved EXPORT_SYMBOL() near the definition
- some code clean up

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 962f831f 20-Apr-2006 Jon Masters <jcm@jonmasters.org>

[PATCH] sound: fix hang in mpu401_uart.c

This fixes a hang in mpu401_uart.c that can occur when the mpu401 interface
is non-existent or otherwise doesn't respond to commands but we issue IO
anyway. snd_mpu401_uart_cmd now returns an error code that is passed up
the stack so that an open() will fail immediately in such cases.

Eventually discovered after wine/cxoffice would constantly cause hard
lockups on my desktop immediately after loading (emulating Windows too
well). Turned out that I'd recently moved my sound cards around and using
/dev/sequencer now talks to a sound card with a broken MPU.

This second version changes -EFAULT to -EIO and frees open resources on
error too. Test booted and seems to work ok.

Signed-off-by: Jon Masters <jcm@jonmasters.org>
Cc: Jaroslav Kysela <perex@suse.cz>
Acked-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# b32425ac 18-Nov-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Fix possible races in timer callbacks

Fix possible races in timer callbacks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 73e77ba0 17-Nov-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Add error messages

Add error messages in the critial error path to be more verbose.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e1fad17b 17-Nov-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Remove xxx_t typedefs: MPU401

Modules: MPU401 UART

Remove xxx_t typedefs from the MPU401-UART and MPU401 drivers

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b1d5776d 10-Oct-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Remove vmalloc wrapper, kfree_nocheck()

- Remove vmalloc wrapper
- Add release_and_free_resource() to remove kfree_nocheck() from each driver
and simplify the code

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 561b220a 09-Sep-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Replace with kzalloc() - others

Documentation,SA11xx UDA1341 driver,Generic drivers,MPU401 UART,OPL3
OPL4,Digigram VX core,I2C cs8427,I2C lib core,I2C tea6330t,L3 drivers
AK4114 receiver,AK4117 receiver,PDAudioCF driver,PPC PMAC driver
SPARC AMD7930 driver,SPARC cs4231 driver,Synth,Common EMU synth
USB generic driver,USB USX2Y
Replace kcalloc(1,..) with kzalloc().

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!