Skip to content

Commit b203dba

Browse files
committed
ALSA: core: Fix missing card sysfs contents
While moving the card device into struct snd_card, the reference to the assigned card in sysfs show/store callbacks were forgotten to be refreshed, still accessing to the no longer used drvdata. Fix these places to refer correctly via container_of(). Also, remove the superfluous NULL checks since it's guaranteed to be non-NULL now. Fixes: 8bfb181 ('ALSA: Embed card device into struct snd_card') Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent dff86f8 commit b203dba

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎sound/core/init.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,15 +624,15 @@ static ssize_t
624624
card_id_show_attr(struct device *dev,
625625
struct device_attribute *attr, char *buf)
626626
{
627-
struct snd_card *card = dev_get_drvdata(dev);
628-
return snprintf(buf, PAGE_SIZE, "%s\n", card ? card->id : "(null)");
627+
struct snd_card *card = container_of(dev, struct snd_card, card_dev);
628+
return snprintf(buf, PAGE_SIZE, "%s\n", card->id);
629629
}
630630

631631
static ssize_t
632632
card_id_store_attr(struct device *dev, struct device_attribute *attr,
633633
const char *buf, size_t count)
634634
{
635-
struct snd_card *card = dev_get_drvdata(dev);
635+
struct snd_card *card = container_of(dev, struct snd_card, card_dev);
636636
char buf1[sizeof(card->id)];
637637
size_t copy = count > sizeof(card->id) - 1 ?
638638
sizeof(card->id) - 1 : count;
@@ -664,8 +664,8 @@ static ssize_t
664664
card_number_show_attr(struct device *dev,
665665
struct device_attribute *attr, char *buf)
666666
{
667-
struct snd_card *card = dev_get_drvdata(dev);
668-
return snprintf(buf, PAGE_SIZE, "%i\n", card ? card->number : -1);
667+
struct snd_card *card = container_of(dev, struct snd_card, card_dev);
668+
return snprintf(buf, PAGE_SIZE, "%i\n", card->number);
669669
}
670670

671671
static DEVICE_ATTR(number, S_IRUGO, card_number_show_attr, NULL);

0 commit comments

Comments
 (0)