Skip to content

Commit

Permalink
device create: sound: convert device_create to device_create_drvdata
Browse files Browse the repository at this point in the history
device_create() is race-prone, so use the race-free
device_create_drvdata() instead as device_create() is going away.

Cc: Jaroslav Kysela <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh committed Jul 22, 2008
1 parent 9def0b9 commit 8940921
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions sound/core/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,9 @@ int snd_card_register(struct snd_card *card)
snd_assert(card != NULL, return -EINVAL);
#ifndef CONFIG_SYSFS_DEPRECATED
if (!card->card_dev) {
card->card_dev = device_create(sound_class, card->dev, 0,
"card%i", card->number);
card->card_dev = device_create_drvdata(sound_class, card->dev,
MKDEV(0, 0), NULL,
"card%i", card->number);
if (IS_ERR(card->card_dev))
card->card_dev = NULL;
}
Expand Down
14 changes: 8 additions & 6 deletions sound/oss/soundcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,17 +560,19 @@ static int __init oss_init(void)
sound_dmap_flag = (dmabuf > 0 ? 1 : 0);

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

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

for (j = 1; j < *dev_list[i].num; j++)
device_create(sound_class, NULL,
MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
"%s%d", dev_list[i].name, j);
device_create_drvdata(sound_class, NULL,
MKDEV(SOUND_MAJOR,
dev_list[i].minor + (j*0x10)),
NULL,
"%s%d", dev_list[i].name, j);
}

if (sound_nblocks >= 1024)
Expand Down
5 changes: 3 additions & 2 deletions sound/sound_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati
else
sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);

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

fail:
Expand Down

0 comments on commit 8940921

Please sign in to comment.