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

mfd: cs5535-mfd: Remove mfd_cell->id hack

The current implementation abuses the platform 'id' mfd_cell member
to index into the correct resources entry. Seeing as enough resource
slots are already available, let's just loop through all available
bars and allocate them to their appropriate slot, even if they happen
to be zero.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>

+2 -12
+2 -12
drivers/mfd/cs5535-mfd.c
··· 63 63 64 64 static struct mfd_cell cs5535_mfd_cells[] = { 65 65 { 66 - .id = SMB_BAR, 67 66 .name = "cs5535-smb", 68 67 .num_resources = 1, 69 68 .resources = &cs5535_mfd_resources[SMB_BAR], 70 69 }, 71 70 { 72 - .id = GPIO_BAR, 73 71 .name = "cs5535-gpio", 74 72 .num_resources = 1, 75 73 .resources = &cs5535_mfd_resources[GPIO_BAR], 76 74 }, 77 75 { 78 - .id = MFGPT_BAR, 79 76 .name = "cs5535-mfgpt", 80 77 .num_resources = 1, 81 78 .resources = &cs5535_mfd_resources[MFGPT_BAR], 82 79 }, 83 80 { 84 - .id = PMS_BAR, 85 81 .name = "cs5535-pms", 86 82 .num_resources = 1, 87 83 .resources = &cs5535_mfd_resources[PMS_BAR], ··· 86 90 .disable = cs5535_mfd_res_disable, 87 91 }, 88 92 { 89 - .id = ACPI_BAR, 90 93 .name = "cs5535-acpi", 91 94 .num_resources = 1, 92 95 .resources = &cs5535_mfd_resources[ACPI_BAR], ··· 103 108 static int cs5535_mfd_probe(struct pci_dev *pdev, 104 109 const struct pci_device_id *id) 105 110 { 106 - int err, i; 111 + int err, bar; 107 112 108 113 err = pci_enable_device(pdev); 109 114 if (err) 110 115 return err; 111 116 112 - /* fill in IO range for each cell; subdrivers handle the region */ 113 - for (i = 0; i < ARRAY_SIZE(cs5535_mfd_cells); i++) { 114 - int bar = cs5535_mfd_cells[i].id; 117 + for (bar = 0; bar < NR_BARS; bar++) { 115 118 struct resource *r = &cs5535_mfd_resources[bar]; 116 119 117 120 r->flags = IORESOURCE_IO; 118 121 r->start = pci_resource_start(pdev, bar); 119 122 r->end = pci_resource_end(pdev, bar); 120 - 121 - /* id is used for temporarily storing BAR; unset it now */ 122 - cs5535_mfd_cells[i].id = 0; 123 123 } 124 124 125 125 err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, cs5535_mfd_cells,