Skip to content

Commit ac9f67b

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci-pci: Let devices define their own private data
Let devices define their own private data to facilitate device-specific operations. The size of the private structure is specified in the sdhci_pci_fixes structure, then sdhci_pci_probe_slot() will allocate extra space for it, and sdhci_pci_priv() can be used to get a reference to it. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
1 parent d38dcad commit ac9f67b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

drivers/mmc/host/sdhci-pci-core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
18301830
struct sdhci_pci_slot *slot;
18311831
struct sdhci_host *host;
18321832
int ret, bar = first_bar + slotno;
1833+
size_t priv_size = chip->fixes ? chip->fixes->priv_size : 0;
18331834

18341835
if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
18351836
dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar);
@@ -1851,7 +1852,7 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
18511852
return ERR_PTR(-ENODEV);
18521853
}
18531854

1854-
host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pci_slot));
1855+
host = sdhci_alloc_host(&pdev->dev, sizeof(*slot) + priv_size);
18551856
if (IS_ERR(host)) {
18561857
dev_err(&pdev->dev, "cannot allocate host\n");
18571858
return ERR_CAST(host);

drivers/mmc/host/sdhci-pci.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct sdhci_pci_fixes {
7070
int (*resume) (struct sdhci_pci_chip *);
7171

7272
const struct sdhci_ops *ops;
73+
size_t priv_size;
7374
};
7475

7576
struct sdhci_pci_slot {
@@ -89,6 +90,7 @@ struct sdhci_pci_slot {
8990
struct mmc_card *card,
9091
unsigned int max_dtr, int host_drv,
9192
int card_drv, int *drv_type);
93+
unsigned long private[0] ____cacheline_aligned;
9294
};
9395

9496
struct sdhci_pci_chip {
@@ -105,4 +107,9 @@ struct sdhci_pci_chip {
105107
struct sdhci_pci_slot *slots[MAX_SLOTS]; /* Pointers to host slots */
106108
};
107109

110+
static inline void *sdhci_pci_priv(struct sdhci_pci_slot *slot)
111+
{
112+
return (void *)slot->private;
113+
}
114+
108115
#endif /* __SDHCI_PCI_H */

0 commit comments

Comments
 (0)