mmc.c (c2f73fd07d2ce4605b404f34395eb734a7ba9967) | mmc.c (51ec92e295d563dd5712d198a7e46c2ae5ccccb2) |
---|---|
1/* 2 * linux/drivers/mmc/core/mmc.c 3 * 4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved. 5 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved. 6 * MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 13#include <linux/err.h> 14 15#include <linux/mmc/host.h> 16#include <linux/mmc/card.h> 17#include <linux/mmc/mmc.h> 18 19#include "core.h" | 1/* 2 * linux/drivers/mmc/core/mmc.c 3 * 4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved. 5 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved. 6 * MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12 13#include <linux/err.h> 14 15#include <linux/mmc/host.h> 16#include <linux/mmc/card.h> 17#include <linux/mmc/mmc.h> 18 19#include "core.h" |
20#include "sysfs.h" | |
21#include "bus.h" 22#include "mmc_ops.h" 23 24static const unsigned int tran_exp[] = { 25 10000, 100000, 1000000, 10000000, 26 0, 0, 0, 0 27}; 28 --- 214 unchanged lines hidden (view full) --- 243 } 244 245out: 246 kfree(ext_csd); 247 248 return err; 249} 250 | 20#include "bus.h" 21#include "mmc_ops.h" 22 23static const unsigned int tran_exp[] = { 24 10000, 100000, 1000000, 10000000, 25 0, 0, 0, 0 26}; 27 --- 214 unchanged lines hidden (view full) --- 242 } 243 244out: 245 kfree(ext_csd); 246 247 return err; 248} 249 |
250MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1], 251 card->raw_cid[2], card->raw_cid[3]); 252MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1], 253 card->raw_csd[2], card->raw_csd[3]); 254MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year); 255MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev); 256MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev); 257MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid); 258MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); 259MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); 260MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); 261 262static struct attribute *mmc_std_attrs[] = { 263 &dev_attr_cid.attr, 264 &dev_attr_csd.attr, 265 &dev_attr_date.attr, 266 &dev_attr_fwrev.attr, 267 &dev_attr_hwrev.attr, 268 &dev_attr_manfid.attr, 269 &dev_attr_name.attr, 270 &dev_attr_oemid.attr, 271 &dev_attr_serial.attr, 272 NULL, 273}; 274 275static struct attribute_group mmc_std_attr_group = { 276 .attrs = mmc_std_attrs, 277}; 278 279static struct attribute_group *mmc_attr_groups[] = { 280 &mmc_std_attr_group, 281 NULL, 282}; 283 284static struct device_type mmc_type = { 285 .groups = mmc_attr_groups, 286}; 287 |
|
251/* 252 * Handle the detection and initialisation of a card. 253 * 254 * In the case of a resume, "curcard" will contain the card 255 * we're trying to reinitialise. 256 */ 257static int mmc_init_card(struct mmc_host *host, u32 ocr, 258 struct mmc_card *oldcard) --- 44 unchanged lines hidden (view full) --- 303 goto err; 304 } 305 306 card = oldcard; 307 } else { 308 /* 309 * Allocate card structure. 310 */ | 288/* 289 * Handle the detection and initialisation of a card. 290 * 291 * In the case of a resume, "curcard" will contain the card 292 * we're trying to reinitialise. 293 */ 294static int mmc_init_card(struct mmc_host *host, u32 ocr, 295 struct mmc_card *oldcard) --- 44 unchanged lines hidden (view full) --- 340 goto err; 341 } 342 343 card = oldcard; 344 } else { 345 /* 346 * Allocate card structure. 347 */ |
311 card = mmc_alloc_card(host); | 348 card = mmc_alloc_card(host, &mmc_type); |
312 if (IS_ERR(card)) { 313 err = PTR_ERR(card); 314 goto err; 315 } 316 317 card->type = MMC_TYPE_MMC; 318 card->rca = 1; 319 memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); --- 134 unchanged lines hidden (view full) --- 454 mmc_remove(host); 455 456 mmc_claim_host(host); 457 mmc_detach_bus(host); 458 mmc_release_host(host); 459 } 460} 461 | 349 if (IS_ERR(card)) { 350 err = PTR_ERR(card); 351 goto err; 352 } 353 354 card->type = MMC_TYPE_MMC; 355 card->rca = 1; 356 memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); --- 134 unchanged lines hidden (view full) --- 491 mmc_remove(host); 492 493 mmc_claim_host(host); 494 mmc_detach_bus(host); 495 mmc_release_host(host); 496 } 497} 498 |
462MMC_ATTR_FN(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1], 463 card->raw_cid[2], card->raw_cid[3]); 464MMC_ATTR_FN(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1], 465 card->raw_csd[2], card->raw_csd[3]); 466MMC_ATTR_FN(date, "%02d/%04d\n", card->cid.month, card->cid.year); 467MMC_ATTR_FN(fwrev, "0x%x\n", card->cid.fwrev); 468MMC_ATTR_FN(hwrev, "0x%x\n", card->cid.hwrev); 469MMC_ATTR_FN(manfid, "0x%06x\n", card->cid.manfid); 470MMC_ATTR_FN(name, "%s\n", card->cid.prod_name); 471MMC_ATTR_FN(oemid, "0x%04x\n", card->cid.oemid); 472MMC_ATTR_FN(serial, "0x%08x\n", card->cid.serial); 473 474static struct device_attribute mmc_dev_attrs[] = { 475 MMC_ATTR_RO(cid), 476 MMC_ATTR_RO(csd), 477 MMC_ATTR_RO(date), 478 MMC_ATTR_RO(fwrev), 479 MMC_ATTR_RO(hwrev), 480 MMC_ATTR_RO(manfid), 481 MMC_ATTR_RO(name), 482 MMC_ATTR_RO(oemid), 483 MMC_ATTR_RO(serial), 484 __ATTR_NULL, 485}; 486 487/* 488 * Adds sysfs entries as relevant. 489 */ 490static int mmc_sysfs_add(struct mmc_host *host, struct mmc_card *card) 491{ 492 int ret; 493 494 ret = mmc_add_attrs(card, mmc_dev_attrs); 495 if (ret < 0) 496 return ret; 497 498 return 0; 499} 500 501/* 502 * Removes the sysfs entries added by mmc_sysfs_add(). 503 */ 504static void mmc_sysfs_remove(struct mmc_host *host, struct mmc_card *card) 505{ 506 mmc_remove_attrs(card, mmc_dev_attrs); 507} 508 | |
509#ifdef CONFIG_MMC_UNSAFE_RESUME 510 511/* 512 * Suspend callback from host. 513 */ 514static void mmc_suspend(struct mmc_host *host) 515{ 516 BUG_ON(!host); --- 38 unchanged lines hidden (view full) --- 555#define mmc_suspend NULL 556#define mmc_resume NULL 557 558#endif 559 560static const struct mmc_bus_ops mmc_ops = { 561 .remove = mmc_remove, 562 .detect = mmc_detect, | 499#ifdef CONFIG_MMC_UNSAFE_RESUME 500 501/* 502 * Suspend callback from host. 503 */ 504static void mmc_suspend(struct mmc_host *host) 505{ 506 BUG_ON(!host); --- 38 unchanged lines hidden (view full) --- 545#define mmc_suspend NULL 546#define mmc_resume NULL 547 548#endif 549 550static const struct mmc_bus_ops mmc_ops = { 551 .remove = mmc_remove, 552 .detect = mmc_detect, |
563 .sysfs_add = mmc_sysfs_add, 564 .sysfs_remove = mmc_sysfs_remove, | |
565 .suspend = mmc_suspend, 566 .resume = mmc_resume, 567}; 568 569/* 570 * Starting point for MMC card init. 571 */ 572int mmc_attach_mmc(struct mmc_host *host, u32 ocr) --- 67 unchanged lines hidden --- | 553 .suspend = mmc_suspend, 554 .resume = mmc_resume, 555}; 556 557/* 558 * Starting point for MMC card init. 559 */ 560int mmc_attach_mmc(struct mmc_host *host, u32 ocr) --- 67 unchanged lines hidden --- |