Merge HEAD from master.kernel.org:/home/rmk/linux-2.6-mmc.git

+112 -22
+13 -16
drivers/mmc/mmc.c
··· 361 362 default: 363 printk("%s: card has unknown MMCA version %d\n", 364 - card->host->host_name, card->csd.mmca_vsn); 365 mmc_card_set_bad(card); 366 break; 367 } ··· 383 csd_struct = UNSTUFF_BITS(resp, 126, 2); 384 if (csd_struct != 1 && csd_struct != 2) { 385 printk("%s: unrecognised CSD structure version %d\n", 386 - card->host->host_name, csd_struct); 387 mmc_card_set_bad(card); 388 return; 389 } ··· 551 } 552 if (err != MMC_ERR_NONE) { 553 printk(KERN_ERR "%s: error requesting CID: %d\n", 554 - host->host_name, err); 555 break; 556 } 557 ··· 796 { 797 struct mmc_host *host; 798 799 - host = kmalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); 800 if (host) { 801 - memset(host, 0, sizeof(struct mmc_host) + extra); 802 - 803 spin_lock_init(&host->lock); 804 init_waitqueue_head(&host->wq); 805 INIT_LIST_HEAD(&host->cards); 806 INIT_WORK(&host->detect, mmc_rescan, host); 807 - 808 - host->dev = dev; 809 810 /* 811 * By default, hosts do not support SGIO or large requests. ··· 824 */ 825 int mmc_add_host(struct mmc_host *host) 826 { 827 - static unsigned int host_num; 828 829 - snprintf(host->host_name, sizeof(host->host_name), 830 - "mmc%d", host_num++); 831 832 - mmc_power_off(host); 833 - mmc_detect_change(host); 834 - 835 - return 0; 836 } 837 838 EXPORT_SYMBOL(mmc_add_host); ··· 855 } 856 857 mmc_power_off(host); 858 } 859 860 EXPORT_SYMBOL(mmc_remove_host); ··· 869 void mmc_free_host(struct mmc_host *host) 870 { 871 flush_scheduled_work(); 872 - kfree(host); 873 } 874 875 EXPORT_SYMBOL(mmc_free_host);
··· 361 362 default: 363 printk("%s: card has unknown MMCA version %d\n", 364 + mmc_hostname(card->host), card->csd.mmca_vsn); 365 mmc_card_set_bad(card); 366 break; 367 } ··· 383 csd_struct = UNSTUFF_BITS(resp, 126, 2); 384 if (csd_struct != 1 && csd_struct != 2) { 385 printk("%s: unrecognised CSD structure version %d\n", 386 + mmc_hostname(card->host), csd_struct); 387 mmc_card_set_bad(card); 388 return; 389 } ··· 551 } 552 if (err != MMC_ERR_NONE) { 553 printk(KERN_ERR "%s: error requesting CID: %d\n", 554 + mmc_hostname(host), err); 555 break; 556 } 557 ··· 796 { 797 struct mmc_host *host; 798 799 + host = mmc_alloc_host_sysfs(extra, dev); 800 if (host) { 801 spin_lock_init(&host->lock); 802 init_waitqueue_head(&host->wq); 803 INIT_LIST_HEAD(&host->cards); 804 INIT_WORK(&host->detect, mmc_rescan, host); 805 806 /* 807 * By default, hosts do not support SGIO or large requests. ··· 828 */ 829 int mmc_add_host(struct mmc_host *host) 830 { 831 + int ret; 832 833 + ret = mmc_add_host_sysfs(host); 834 + if (ret == 0) { 835 + mmc_power_off(host); 836 + mmc_detect_change(host); 837 + } 838 839 + return ret; 840 } 841 842 EXPORT_SYMBOL(mmc_add_host); ··· 859 } 860 861 mmc_power_off(host); 862 + mmc_remove_host_sysfs(host); 863 } 864 865 EXPORT_SYMBOL(mmc_remove_host); ··· 872 void mmc_free_host(struct mmc_host *host) 873 { 874 flush_scheduled_work(); 875 + mmc_free_host_sysfs(host); 876 } 877 878 EXPORT_SYMBOL(mmc_free_host);
+5
drivers/mmc/mmc.h
··· 13 void mmc_init_card(struct mmc_card *card, struct mmc_host *host); 14 int mmc_register_card(struct mmc_card *card); 15 void mmc_remove_card(struct mmc_card *card); 16 #endif
··· 13 void mmc_init_card(struct mmc_card *card, struct mmc_host *host); 14 int mmc_register_card(struct mmc_card *card); 15 void mmc_remove_card(struct mmc_card *card); 16 + 17 + struct mmc_host *mmc_alloc_host_sysfs(int extra, struct device *dev); 18 + int mmc_add_host_sysfs(struct mmc_host *host); 19 + void mmc_remove_host_sysfs(struct mmc_host *host); 20 + void mmc_free_host_sysfs(struct mmc_host *host); 21 #endif
+88 -2
drivers/mmc/mmc_sysfs.c
··· 12 #include <linux/module.h> 13 #include <linux/init.h> 14 #include <linux/device.h> 15 16 #include <linux/mmc/card.h> 17 #include <linux/mmc/host.h> ··· 21 22 #define dev_to_mmc_card(d) container_of(d, struct mmc_card, dev) 23 #define to_mmc_driver(d) container_of(d, struct mmc_driver, drv) 24 25 #define MMC_ATTR(name, fmt, args...) \ 26 static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf) \ ··· 208 int mmc_register_card(struct mmc_card *card) 209 { 210 snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), 211 - "%s:%04x", card->host->host_name, card->rca); 212 213 return device_add(&card->dev); 214 } ··· 226 } 227 228 229 static int __init mmc_init(void) 230 { 231 - return bus_register(&mmc_bus_type); 232 } 233 234 static void __exit mmc_exit(void) 235 { 236 bus_unregister(&mmc_bus_type); 237 } 238
··· 12 #include <linux/module.h> 13 #include <linux/init.h> 14 #include <linux/device.h> 15 + #include <linux/idr.h> 16 17 #include <linux/mmc/card.h> 18 #include <linux/mmc/host.h> ··· 20 21 #define dev_to_mmc_card(d) container_of(d, struct mmc_card, dev) 22 #define to_mmc_driver(d) container_of(d, struct mmc_driver, drv) 23 + #define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev) 24 25 #define MMC_ATTR(name, fmt, args...) \ 26 static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf) \ ··· 206 int mmc_register_card(struct mmc_card *card) 207 { 208 snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), 209 + "%s:%04x", mmc_hostname(card->host), card->rca); 210 211 return device_add(&card->dev); 212 } ··· 224 } 225 226 227 + static void mmc_host_classdev_release(struct class_device *dev) 228 + { 229 + struct mmc_host *host = cls_dev_to_mmc_host(dev); 230 + kfree(host); 231 + } 232 + 233 + static struct class mmc_host_class = { 234 + .name = "mmc_host", 235 + .release = mmc_host_classdev_release, 236 + }; 237 + 238 + static DEFINE_IDR(mmc_host_idr); 239 + static DEFINE_SPINLOCK(mmc_host_lock); 240 + 241 + /* 242 + * Internal function. Allocate a new MMC host. 243 + */ 244 + struct mmc_host *mmc_alloc_host_sysfs(int extra, struct device *dev) 245 + { 246 + struct mmc_host *host; 247 + 248 + host = kmalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); 249 + if (host) { 250 + memset(host, 0, sizeof(struct mmc_host) + extra); 251 + 252 + host->dev = dev; 253 + host->class_dev.dev = host->dev; 254 + host->class_dev.class = &mmc_host_class; 255 + class_device_initialize(&host->class_dev); 256 + } 257 + 258 + return host; 259 + } 260 + 261 + /* 262 + * Internal function. Register a new MMC host with the MMC class. 263 + */ 264 + int mmc_add_host_sysfs(struct mmc_host *host) 265 + { 266 + int err; 267 + 268 + if (!idr_pre_get(&mmc_host_idr, GFP_KERNEL)) 269 + return -ENOMEM; 270 + 271 + spin_lock(&mmc_host_lock); 272 + err = idr_get_new(&mmc_host_idr, host, &host->index); 273 + spin_unlock(&mmc_host_lock); 274 + if (err) 275 + return err; 276 + 277 + snprintf(host->class_dev.class_id, BUS_ID_SIZE, 278 + "mmc%d", host->index); 279 + 280 + return class_device_add(&host->class_dev); 281 + } 282 + 283 + /* 284 + * Internal function. Unregister a MMC host with the MMC class. 285 + */ 286 + void mmc_remove_host_sysfs(struct mmc_host *host) 287 + { 288 + class_device_del(&host->class_dev); 289 + 290 + spin_lock(&mmc_host_lock); 291 + idr_remove(&mmc_host_idr, host->index); 292 + spin_unlock(&mmc_host_lock); 293 + } 294 + 295 + /* 296 + * Internal function. Free a MMC host. 297 + */ 298 + void mmc_free_host_sysfs(struct mmc_host *host) 299 + { 300 + class_device_put(&host->class_dev); 301 + } 302 + 303 + 304 static int __init mmc_init(void) 305 { 306 + int ret = bus_register(&mmc_bus_type); 307 + if (ret == 0) { 308 + ret = class_register(&mmc_host_class); 309 + if (ret) 310 + bus_unregister(&mmc_bus_type); 311 + } 312 + return ret; 313 } 314 315 static void __exit mmc_exit(void) 316 { 317 + class_unregister(&mmc_host_class); 318 bus_unregister(&mmc_bus_type); 319 } 320
+2 -2
drivers/mmc/mmci.c
··· 34 35 #ifdef CONFIG_MMC_DEBUG 36 #define DBG(host,fmt,args...) \ 37 - pr_debug("%s: %s: " fmt, host->mmc->host_name, __func__ , args) 38 #else 39 #define DBG(host,fmt,args...) do { } while (0) 40 #endif ··· 541 mmc_add_host(mmc); 542 543 printk(KERN_INFO "%s: MMCI rev %x cfg %02x at 0x%08lx irq %d,%d\n", 544 - mmc->host_name, amba_rev(dev), amba_config(dev), 545 dev->res.start, dev->irq[0], dev->irq[1]); 546 547 init_timer(&host->timer);
··· 34 35 #ifdef CONFIG_MMC_DEBUG 36 #define DBG(host,fmt,args...) \ 37 + pr_debug("%s: %s: " fmt, mmc_hostname(host->mmc), __func__ , args) 38 #else 39 #define DBG(host,fmt,args...) do { } while (0) 40 #endif ··· 541 mmc_add_host(mmc); 542 543 printk(KERN_INFO "%s: MMCI rev %x cfg %02x at 0x%08lx irq %d,%d\n", 544 + mmc_hostname(mmc), amba_rev(dev), amba_config(dev), 545 dev->res.start, dev->irq[0], dev->irq[1]); 546 547 init_timer(&host->timer);
+1 -1
drivers/mmc/wbsd.c
··· 1796 1797 mmc_add_host(mmc); 1798 1799 - printk(KERN_INFO "%s: W83L51xD", mmc->host_name); 1800 if (host->chip_id != 0) 1801 printk(" id %x", (int)host->chip_id); 1802 printk(" at 0x%x irq %d", (int)host->base, (int)host->irq);
··· 1796 1797 mmc_add_host(mmc); 1798 1799 + printk(KERN_INFO "%s: W83L51xD", mmc_hostname(mmc)); 1800 if (host->chip_id != 0) 1801 printk(" id %x", (int)host->chip_id); 1802 printk(" at 0x%x irq %d", (int)host->base, (int)host->irq);
+3 -1
include/linux/mmc/host.h
··· 63 64 struct mmc_host { 65 struct device *dev; 66 struct mmc_host_ops *ops; 67 unsigned int f_min; 68 unsigned int f_max; 69 u32 ocr_avail; 70 - char host_name[8]; 71 72 /* host specific block data */ 73 unsigned int max_seg_size; /* see blk_queue_max_segment_size */ ··· 98 99 #define mmc_priv(x) ((void *)((x) + 1)) 100 #define mmc_dev(x) ((x)->dev) 101 102 extern int mmc_suspend_host(struct mmc_host *, pm_message_t); 103 extern int mmc_resume_host(struct mmc_host *);
··· 63 64 struct mmc_host { 65 struct device *dev; 66 + struct class_device class_dev; 67 + int index; 68 struct mmc_host_ops *ops; 69 unsigned int f_min; 70 unsigned int f_max; 71 u32 ocr_avail; 72 73 /* host specific block data */ 74 unsigned int max_seg_size; /* see blk_queue_max_segment_size */ ··· 97 98 #define mmc_priv(x) ((void *)((x) + 1)) 99 #define mmc_dev(x) ((x)->dev) 100 + #define mmc_hostname(x) ((x)->class_dev.class_id) 101 102 extern int mmc_suspend_host(struct mmc_host *, pm_message_t); 103 extern int mmc_resume_host(struct mmc_host *);