Skip to content

Commit 8940921

Browse files
committed
device create: sound: convert device_create to device_create_drvdata
device_create() is race-prone, so use the race-free device_create_drvdata() instead as device_create() is going away. Cc: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 9def0b9 commit 8940921

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

‎sound/core/init.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,9 @@ int snd_card_register(struct snd_card *card)
548548
snd_assert(card != NULL, return -EINVAL);
549549
#ifndef CONFIG_SYSFS_DEPRECATED
550550
if (!card->card_dev) {
551-
card->card_dev = device_create(sound_class, card->dev, 0,
552-
"card%i", card->number);
551+
card->card_dev = device_create_drvdata(sound_class, card->dev,
552+
MKDEV(0, 0), NULL,
553+
"card%i", card->number);
553554
if (IS_ERR(card->card_dev))
554555
card->card_dev = NULL;
555556
}

‎sound/oss/soundcard.c‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,17 +560,19 @@ static int __init oss_init(void)
560560
sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
561561

562562
for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
563-
device_create(sound_class, NULL,
564-
MKDEV(SOUND_MAJOR, dev_list[i].minor),
565-
"%s", dev_list[i].name);
563+
device_create_drvdata(sound_class, NULL,
564+
MKDEV(SOUND_MAJOR, dev_list[i].minor),
565+
NULL, "%s", dev_list[i].name);
566566

567567
if (!dev_list[i].num)
568568
continue;
569569

570570
for (j = 1; j < *dev_list[i].num; j++)
571-
device_create(sound_class, NULL,
572-
MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
573-
"%s%d", dev_list[i].name, j);
571+
device_create_drvdata(sound_class, NULL,
572+
MKDEV(SOUND_MAJOR,
573+
dev_list[i].minor + (j*0x10)),
574+
NULL,
575+
"%s%d", dev_list[i].name, j);
574576
}
575577

576578
if (sound_nblocks >= 1024)

‎sound/sound_core.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati
171171
else
172172
sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);
173173

174-
device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
175-
s->name+6);
174+
device_create_drvdata(sound_class, dev,
175+
MKDEV(SOUND_MAJOR, s->unit_minor),
176+
NULL, s->name+6);
176177
return r;
177178

178179
fail:

0 commit comments

Comments
 (0)