Skip to content

Commit 66c21c5

Browse files
committed
Merge branch 'topic/cleanup' into for-next
2 parents dec8431 + 0c8d948 commit 66c21c5

File tree

2 files changed

+40
-115
lines changed

2 files changed

+40
-115
lines changed

sound/core/sound.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static const struct file_operations snd_fops =
186186
};
187187

188188
#ifdef CONFIG_SND_DYNAMIC_MINORS
189-
static int snd_find_free_minor(int type)
189+
static int snd_find_free_minor(int type, struct snd_card *card, int dev)
190190
{
191191
int minor;
192192

@@ -209,7 +209,7 @@ static int snd_find_free_minor(int type)
209209
return -EBUSY;
210210
}
211211
#else
212-
static int snd_kernel_minor(int type, struct snd_card *card, int dev)
212+
static int snd_find_free_minor(int type, struct snd_card *card, int dev)
213213
{
214214
int minor;
215215

@@ -237,6 +237,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
237237
}
238238
if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS))
239239
return -EINVAL;
240+
if (snd_minors[minor])
241+
return -EBUSY;
240242
return minor;
241243
}
242244
#endif
@@ -276,13 +278,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
276278
preg->private_data = private_data;
277279
preg->card_ptr = card;
278280
mutex_lock(&sound_mutex);
279-
#ifdef CONFIG_SND_DYNAMIC_MINORS
280-
minor = snd_find_free_minor(type);
281-
#else
282-
minor = snd_kernel_minor(type, card, dev);
283-
if (minor >= 0 && snd_minors[minor])
284-
minor = -EBUSY;
285-
#endif
281+
minor = snd_find_free_minor(type, card, dev);
286282
if (minor < 0) {
287283
err = minor;
288284
goto error;

sound/pci/rme9652/hdspm.c

Lines changed: 35 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -6043,23 +6043,30 @@ hdspm_hw_constraints_aes32_sample_rates = {
60436043
.mask = 0
60446044
};
60456045

6046-
static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
6046+
static int snd_hdspm_open(struct snd_pcm_substream *substream)
60476047
{
60486048
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
60496049
struct snd_pcm_runtime *runtime = substream->runtime;
6050+
bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
60506051

60516052
spin_lock_irq(&hdspm->lock);
6052-
60536053
snd_pcm_set_sync(substream);
6054+
runtime->hw = (playback) ? snd_hdspm_playback_subinfo :
6055+
snd_hdspm_capture_subinfo;
60546056

6057+
if (playback) {
6058+
if (hdspm->capture_substream == NULL)
6059+
hdspm_stop_audio(hdspm);
60556060

6056-
runtime->hw = snd_hdspm_playback_subinfo;
6057-
6058-
if (hdspm->capture_substream == NULL)
6059-
hdspm_stop_audio(hdspm);
6061+
hdspm->playback_pid = current->pid;
6062+
hdspm->playback_substream = substream;
6063+
} else {
6064+
if (hdspm->playback_substream == NULL)
6065+
hdspm_stop_audio(hdspm);
60606066

6061-
hdspm->playback_pid = current->pid;
6062-
hdspm->playback_substream = substream;
6067+
hdspm->capture_pid = current->pid;
6068+
hdspm->capture_substream = substream;
6069+
}
60636070

60646071
spin_unlock_irq(&hdspm->lock);
60656072

@@ -6094,108 +6101,42 @@ static int snd_hdspm_playback_open(struct snd_pcm_substream *substream)
60946101
&hdspm_hw_constraints_aes32_sample_rates);
60956102
} else {
60966103
snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
6097-
snd_hdspm_hw_rule_rate_out_channels, hdspm,
6104+
(playback ?
6105+
snd_hdspm_hw_rule_rate_out_channels :
6106+
snd_hdspm_hw_rule_rate_in_channels), hdspm,
60986107
SNDRV_PCM_HW_PARAM_CHANNELS, -1);
60996108
}
61006109

61016110
snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
6102-
snd_hdspm_hw_rule_out_channels, hdspm,
6111+
(playback ? snd_hdspm_hw_rule_out_channels :
6112+
snd_hdspm_hw_rule_in_channels), hdspm,
61036113
SNDRV_PCM_HW_PARAM_CHANNELS, -1);
61046114

61056115
snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
6106-
snd_hdspm_hw_rule_out_channels_rate, hdspm,
6116+
(playback ? snd_hdspm_hw_rule_out_channels_rate :
6117+
snd_hdspm_hw_rule_in_channels_rate), hdspm,
61076118
SNDRV_PCM_HW_PARAM_RATE, -1);
61086119

61096120
return 0;
61106121
}
61116122

6112-
static int snd_hdspm_playback_release(struct snd_pcm_substream *substream)
6123+
static int snd_hdspm_release(struct snd_pcm_substream *substream)
61136124
{
61146125
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
6126+
bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK);
61156127

61166128
spin_lock_irq(&hdspm->lock);
61176129

6118-
hdspm->playback_pid = -1;
6119-
hdspm->playback_substream = NULL;
6120-
6121-
spin_unlock_irq(&hdspm->lock);
6122-
6123-
return 0;
6124-
}
6125-
6126-
6127-
static int snd_hdspm_capture_open(struct snd_pcm_substream *substream)
6128-
{
6129-
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
6130-
struct snd_pcm_runtime *runtime = substream->runtime;
6131-
6132-
spin_lock_irq(&hdspm->lock);
6133-
snd_pcm_set_sync(substream);
6134-
runtime->hw = snd_hdspm_capture_subinfo;
6135-
6136-
if (hdspm->playback_substream == NULL)
6137-
hdspm_stop_audio(hdspm);
6138-
6139-
hdspm->capture_pid = current->pid;
6140-
hdspm->capture_substream = substream;
6141-
6142-
spin_unlock_irq(&hdspm->lock);
6143-
6144-
snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
6145-
snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
6146-
6147-
switch (hdspm->io_type) {
6148-
case AIO:
6149-
case RayDAT:
6150-
snd_pcm_hw_constraint_minmax(runtime,
6151-
SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
6152-
32, 4096);
6153-
snd_pcm_hw_constraint_minmax(runtime,
6154-
SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
6155-
16384, 16384);
6156-
break;
6157-
6158-
default:
6159-
snd_pcm_hw_constraint_minmax(runtime,
6160-
SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
6161-
64, 8192);
6162-
snd_pcm_hw_constraint_minmax(runtime,
6163-
SNDRV_PCM_HW_PARAM_PERIODS,
6164-
2, 2);
6165-
break;
6166-
}
6167-
6168-
if (AES32 == hdspm->io_type) {
6169-
runtime->hw.rates |= SNDRV_PCM_RATE_KNOT;
6170-
snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
6171-
&hdspm_hw_constraints_aes32_sample_rates);
6130+
if (playback) {
6131+
hdspm->playback_pid = -1;
6132+
hdspm->playback_substream = NULL;
61726133
} else {
6173-
snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
6174-
snd_hdspm_hw_rule_rate_in_channels, hdspm,
6175-
SNDRV_PCM_HW_PARAM_CHANNELS, -1);
6134+
hdspm->capture_pid = -1;
6135+
hdspm->capture_substream = NULL;
61766136
}
61776137

6178-
snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
6179-
snd_hdspm_hw_rule_in_channels, hdspm,
6180-
SNDRV_PCM_HW_PARAM_CHANNELS, -1);
6181-
6182-
snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
6183-
snd_hdspm_hw_rule_in_channels_rate, hdspm,
6184-
SNDRV_PCM_HW_PARAM_RATE, -1);
6185-
6186-
return 0;
6187-
}
6188-
6189-
static int snd_hdspm_capture_release(struct snd_pcm_substream *substream)
6190-
{
6191-
struct hdspm *hdspm = snd_pcm_substream_chip(substream);
6192-
6193-
spin_lock_irq(&hdspm->lock);
6194-
6195-
hdspm->capture_pid = -1;
6196-
hdspm->capture_substream = NULL;
6197-
61986138
spin_unlock_irq(&hdspm->lock);
6139+
61996140
return 0;
62006141
}
62016142

@@ -6413,21 +6354,9 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
64136354
return 0;
64146355
}
64156356

6416-
static struct snd_pcm_ops snd_hdspm_playback_ops = {
6417-
.open = snd_hdspm_playback_open,
6418-
.close = snd_hdspm_playback_release,
6419-
.ioctl = snd_hdspm_ioctl,
6420-
.hw_params = snd_hdspm_hw_params,
6421-
.hw_free = snd_hdspm_hw_free,
6422-
.prepare = snd_hdspm_prepare,
6423-
.trigger = snd_hdspm_trigger,
6424-
.pointer = snd_hdspm_hw_pointer,
6425-
.page = snd_pcm_sgbuf_ops_page,
6426-
};
6427-
6428-
static struct snd_pcm_ops snd_hdspm_capture_ops = {
6429-
.open = snd_hdspm_capture_open,
6430-
.close = snd_hdspm_capture_release,
6357+
static struct snd_pcm_ops snd_hdspm_ops = {
6358+
.open = snd_hdspm_open,
6359+
.close = snd_hdspm_release,
64316360
.ioctl = snd_hdspm_ioctl,
64326361
.hw_params = snd_hdspm_hw_params,
64336362
.hw_free = snd_hdspm_hw_free,
@@ -6521,9 +6450,9 @@ static int snd_hdspm_create_pcm(struct snd_card *card,
65216450
strcpy(pcm->name, hdspm->card_name);
65226451

65236452
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
6524-
&snd_hdspm_playback_ops);
6453+
&snd_hdspm_ops);
65256454
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
6526-
&snd_hdspm_capture_ops);
6455+
&snd_hdspm_ops);
65276456

65286457
pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
65296458

0 commit comments

Comments
 (0)