From: Pierre Ossman Date: Tue, 6 Sep 2005 22:18:58 +0000 (-0700) Subject: [PATCH] mmc: conditional scr sysfs entry X-Git-Tag: v2.6.14-rc1~588 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bc20a8d497e137c0a9ee9a3bacce3dd4a2b6993;p=linux-2.6 [PATCH] mmc: conditional scr sysfs entry Only show the scr file in sysfs for SD cards. Previously this was present for all cards but had a contents of 0 for MMC cards. Signed-off-by: Pierre Ossman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c index 9e23ad3ae2..3f4a66ca95 100644 --- a/drivers/mmc/mmc_sysfs.c +++ b/drivers/mmc/mmc_sysfs.c @@ -48,7 +48,6 @@ MMC_ATTR(serial, "0x%08x\n", card->cid.serial); static struct device_attribute mmc_dev_attrs[] = { MMC_ATTR_RO(cid), MMC_ATTR_RO(csd), - MMC_ATTR_RO(scr), MMC_ATTR_RO(date), MMC_ATTR_RO(fwrev), MMC_ATTR_RO(hwrev), @@ -59,6 +58,8 @@ static struct device_attribute mmc_dev_attrs[] = { __ATTR_NULL }; +static struct device_attribute mmc_dev_attr_scr = MMC_ATTR_RO(scr); + static void mmc_release_card(struct device *dev) { @@ -209,10 +210,20 @@ void mmc_init_card(struct mmc_card *card, struct mmc_host *host) */ int mmc_register_card(struct mmc_card *card) { + int ret; + snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), "%s:%04x", mmc_hostname(card->host), card->rca); - return device_add(&card->dev); + ret = device_add(&card->dev); + if (ret == 0) { + if (mmc_card_sd(card)) { + ret = device_create_file(&card->dev, &mmc_dev_attr_scr); + if (ret) + device_del(&card->dev); + } + } + return ret; } /* @@ -221,8 +232,12 @@ int mmc_register_card(struct mmc_card *card) */ void mmc_remove_card(struct mmc_card *card) { - if (mmc_card_present(card)) + if (mmc_card_present(card)) { + if (mmc_card_sd(card)) + device_remove_file(&card->dev, &mmc_dev_attr_scr); + device_del(&card->dev); + } put_device(&card->dev); }