Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.o-hand.com/linux-mfd

* 'for-linus' of git://git.o-hand.com/linux-mfd:
mfd: accept pure device as a parent, not only platform_device
mfd: add platform_data to mfd_cell
mfd: Coding style fixes
mfd: Use to_platform_device instead of container_of

+36 -34
+15 -17
drivers/mfd/mfd-core.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/mfd/core.h> 17 17 18 - static int mfd_add_device(struct platform_device *parent, 19 - const struct mfd_cell *cell, 20 - struct resource *mem_base, 21 - int irq_base) 18 + static int mfd_add_device(struct device *parent, int id, 19 + const struct mfd_cell *cell, 20 + struct resource *mem_base, 21 + int irq_base) 22 22 { 23 23 struct resource res[cell->num_resources]; 24 24 struct platform_device *pdev; 25 25 int ret = -ENOMEM; 26 26 int r; 27 27 28 - pdev = platform_device_alloc(cell->name, parent->id); 28 + pdev = platform_device_alloc(cell->name, id); 29 29 if (!pdev) 30 30 goto fail_alloc; 31 31 32 - pdev->dev.parent = &parent->dev; 32 + pdev->dev.parent = parent; 33 33 34 34 ret = platform_device_add_data(pdev, 35 - cell, sizeof(struct mfd_cell)); 35 + cell->platform_data, cell->data_size); 36 36 if (ret) 37 37 goto fail_device; 38 38 ··· 75 75 return ret; 76 76 } 77 77 78 - int mfd_add_devices( 79 - struct platform_device *parent, 80 - const struct mfd_cell *cells, int n_devs, 81 - struct resource *mem_base, 82 - int irq_base) 78 + int mfd_add_devices(struct device *parent, int id, 79 + const struct mfd_cell *cells, int n_devs, 80 + struct resource *mem_base, 81 + int irq_base) 83 82 { 84 83 int i; 85 84 int ret = 0; 86 85 87 86 for (i = 0; i < n_devs; i++) { 88 - ret = mfd_add_device(parent, cells + i, mem_base, irq_base); 87 + ret = mfd_add_device(parent, id, cells + i, mem_base, irq_base); 89 88 if (ret) 90 89 break; 91 90 } ··· 98 99 99 100 static int mfd_remove_devices_fn(struct device *dev, void *unused) 100 101 { 101 - platform_device_unregister( 102 - container_of(dev, struct platform_device, dev)); 102 + platform_device_unregister(to_platform_device(dev)); 103 103 return 0; 104 104 } 105 105 106 - void mfd_remove_devices(struct platform_device *parent) 106 + void mfd_remove_devices(struct device *parent) 107 107 { 108 - device_for_each_child(&parent->dev, NULL, mfd_remove_devices_fn); 108 + device_for_each_child(parent, NULL, mfd_remove_devices_fn); 109 109 } 110 110 EXPORT_SYMBOL(mfd_remove_devices); 111 111
+6 -2
drivers/mfd/tc6393xb.c
··· 466 466 tc6393xb_attach_irq(dev); 467 467 468 468 tc6393xb_cells[TC6393XB_CELL_NAND].driver_data = tcpd->nand_data; 469 + tc6393xb_cells[TC6393XB_CELL_NAND].platform_data = 470 + &tc6393xb_cells[TC6393XB_CELL_NAND]; 471 + tc6393xb_cells[TC6393XB_CELL_NAND].data_size = 472 + sizeof(tc6393xb_cells[TC6393XB_CELL_NAND]); 469 473 470 - retval = mfd_add_devices(dev, 474 + retval = mfd_add_devices(&dev->dev, dev->id, 471 475 tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells), 472 476 iomem, tcpd->irq_base); 473 477 ··· 505 501 struct tc6393xb *tc6393xb = platform_get_drvdata(dev); 506 502 int ret; 507 503 508 - mfd_remove_devices(dev); 504 + mfd_remove_devices(&dev->dev); 509 505 510 506 if (tc6393xb->irq) 511 507 tc6393xb_detach_irq(dev);
+15 -15
include/linux/mfd/core.h
··· 1 - #ifndef MFD_CORE_H 2 - #define MFD_CORE_H 3 1 /* 4 2 * drivers/mfd/mfd-core.h 5 3 * ··· 10 12 * published by the Free Software Foundation. 11 13 * 12 14 */ 15 + 16 + #ifndef MFD_CORE_H 17 + #define MFD_CORE_H 13 18 14 19 #include <linux/platform_device.h> 15 20 ··· 29 28 int (*suspend)(struct platform_device *dev); 30 29 int (*resume)(struct platform_device *dev); 31 30 32 - void *driver_data; /* driver-specific data */ 31 + /* driver-specific data for MFD-aware "cell" drivers */ 32 + void *driver_data; 33 + 34 + /* platform_data can be used to either pass data to "generic" 35 + driver or as a hook to mfd_cell for the "cell" drivers */ 36 + void *platform_data; 37 + size_t data_size; 33 38 34 39 /* 35 40 * This resources can be specified relatievly to the parent device. ··· 45 38 const struct resource *resources; 46 39 }; 47 40 48 - static inline struct mfd_cell * 49 - mfd_get_cell(struct platform_device *pdev) 50 - { 51 - return (struct mfd_cell *)pdev->dev.platform_data; 52 - } 41 + extern int mfd_add_devices(struct device *parent, int id, 42 + const struct mfd_cell *cells, int n_devs, 43 + struct resource *mem_base, 44 + int irq_base); 53 45 54 - extern int mfd_add_devices( 55 - struct platform_device *parent, 56 - const struct mfd_cell *cells, int n_devs, 57 - struct resource *mem_base, 58 - int irq_base); 59 - 60 - extern void mfd_remove_devices(struct platform_device *parent); 46 + extern void mfd_remove_devices(struct device *parent); 61 47 62 48 #endif