aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/sd.c
diff options
context:
space:
mode:
authorPierre Ossman <drzeus-list@drzeus.cx>2008-03-21 18:54:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-03-22 20:02:20 -0400
commit51ec92e295d563dd5712d198a7e46c2ae5ccccb2 (patch)
treefa45408fad483e89b29900b8ca5adf4bb3164467 /drivers/mmc/core/sd.c
parent03c086a747d0b242878eb881971ec61c1555869d (diff)
mmc: use sysfs groups to handle conditional attributes
Suppressing uevents turned out to be a bad idea as it screws up the order of events, making user space very confused. Change the system to use sysfs groups instead. This is a regression that, for some odd reason, has gone unnoticed for some time. It confuses hal so that the block devices (which have the mmc device as a parent) are not registered. End result being that desktop magic when cards are inserted won't work. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mmc/core/sd.c')
-rw-r--r--drivers/mmc/core/sd.c95
1 files changed, 42 insertions, 53 deletions
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index d1c1e0f592f1..7ef3b15c5e3d 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -18,7 +18,6 @@
18#include <linux/mmc/sd.h> 18#include <linux/mmc/sd.h>
19 19
20#include "core.h" 20#include "core.h"
21#include "sysfs.h"
22#include "bus.h" 21#include "bus.h"
23#include "mmc_ops.h" 22#include "mmc_ops.h"
24#include "sd_ops.h" 23#include "sd_ops.h"
@@ -283,6 +282,47 @@ out:
283 return err; 282 return err;
284} 283}
285 284
285MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
286 card->raw_cid[2], card->raw_cid[3]);
287MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
288 card->raw_csd[2], card->raw_csd[3]);
289MMC_DEV_ATTR(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]);
290MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year);
291MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev);
292MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev);
293MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
294MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
295MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
296MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
297
298
299static struct attribute *sd_std_attrs[] = {
300 &dev_attr_cid.attr,
301 &dev_attr_csd.attr,
302 &dev_attr_scr.attr,
303 &dev_attr_date.attr,
304 &dev_attr_fwrev.attr,
305 &dev_attr_hwrev.attr,
306 &dev_attr_manfid.attr,
307 &dev_attr_name.attr,
308 &dev_attr_oemid.attr,
309 &dev_attr_serial.attr,
310 NULL,
311};
312
313static struct attribute_group sd_std_attr_group = {
314 .attrs = sd_std_attrs,
315};
316
317static struct attribute_group *sd_attr_groups[] = {
318 &sd_std_attr_group,
319 NULL,
320};
321
322static struct device_type sd_type = {
323 .groups = sd_attr_groups,
324};
325
286/* 326/*
287 * Handle the detection and initialisation of a card. 327 * Handle the detection and initialisation of a card.
288 * 328 *
@@ -352,7 +392,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
352 /* 392 /*
353 * Allocate card structure. 393 * Allocate card structure.
354 */ 394 */
355 card = mmc_alloc_card(host); 395 card = mmc_alloc_card(host, &sd_type);
356 if (IS_ERR(card)) { 396 if (IS_ERR(card)) {
357 err = PTR_ERR(card); 397 err = PTR_ERR(card);
358 goto err; 398 goto err;
@@ -518,55 +558,6 @@ static void mmc_sd_detect(struct mmc_host *host)
518 } 558 }
519} 559}
520 560
521MMC_ATTR_FN(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
522 card->raw_cid[2], card->raw_cid[3]);
523MMC_ATTR_FN(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
524 card->raw_csd[2], card->raw_csd[3]);
525MMC_ATTR_FN(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]);
526MMC_ATTR_FN(date, "%02d/%04d\n", card->cid.month, card->cid.year);
527MMC_ATTR_FN(fwrev, "0x%x\n", card->cid.fwrev);
528MMC_ATTR_FN(hwrev, "0x%x\n", card->cid.hwrev);
529MMC_ATTR_FN(manfid, "0x%06x\n", card->cid.manfid);
530MMC_ATTR_FN(name, "%s\n", card->cid.prod_name);
531MMC_ATTR_FN(oemid, "0x%04x\n", card->cid.oemid);
532MMC_ATTR_FN(serial, "0x%08x\n", card->cid.serial);
533
534static struct device_attribute mmc_sd_dev_attrs[] = {
535 MMC_ATTR_RO(cid),
536 MMC_ATTR_RO(csd),
537 MMC_ATTR_RO(scr),
538 MMC_ATTR_RO(date),
539 MMC_ATTR_RO(fwrev),
540 MMC_ATTR_RO(hwrev),
541 MMC_ATTR_RO(manfid),
542 MMC_ATTR_RO(name),
543 MMC_ATTR_RO(oemid),
544 MMC_ATTR_RO(serial),
545 __ATTR_NULL,
546};
547
548/*
549 * Adds sysfs entries as relevant.
550 */
551static int mmc_sd_sysfs_add(struct mmc_host *host, struct mmc_card *card)
552{
553 int ret;
554
555 ret = mmc_add_attrs(card, mmc_sd_dev_attrs);
556 if (ret < 0)
557 return ret;
558
559 return 0;
560}
561
562/*
563 * Removes the sysfs entries added by mmc_sysfs_add().
564 */
565static void mmc_sd_sysfs_remove(struct mmc_host *host, struct mmc_card *card)
566{
567 mmc_remove_attrs(card, mmc_sd_dev_attrs);
568}
569
570#ifdef CONFIG_MMC_UNSAFE_RESUME 561#ifdef CONFIG_MMC_UNSAFE_RESUME
571 562
572/* 563/*
@@ -621,8 +612,6 @@ static void mmc_sd_resume(struct mmc_host *host)
621static const struct mmc_bus_ops mmc_sd_ops = { 612static const struct mmc_bus_ops mmc_sd_ops = {
622 .remove = mmc_sd_remove, 613 .remove = mmc_sd_remove,
623 .detect = mmc_sd_detect, 614 .detect = mmc_sd_detect,
624 .sysfs_add = mmc_sd_sysfs_add,
625 .sysfs_remove = mmc_sd_sysfs_remove,
626 .suspend = mmc_sd_suspend, 615 .suspend = mmc_sd_suspend,
627 .resume = mmc_sd_resume, 616 .resume = mmc_sd_resume,
628}; 617};