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

[MMC] Ensure correct mmc_priv() behaviour

mmc_priv() has some nasty effects if the wrong pointer type is
passed to it. Introduce type checking, which also means we get
the right type. Also add an additional member to mmc_host which
is used to align host-private data appropriately.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Russell King and committed by
Russell King
01357dca 8dc00335

+7 -1
+7 -1
include/linux/mmc/host.h
··· 109 109 struct mmc_card *card_selected; /* the selected MMC card */ 110 110 111 111 struct work_struct detect; 112 + 113 + unsigned long private[0] ____cacheline_aligned; 112 114 }; 113 115 114 116 extern struct mmc_host *mmc_alloc_host(int extra, struct device *); ··· 118 116 extern void mmc_remove_host(struct mmc_host *); 119 117 extern void mmc_free_host(struct mmc_host *); 120 118 121 - #define mmc_priv(x) ((void *)((x) + 1)) 119 + static inline void *mmc_priv(struct mmc_host *host) 120 + { 121 + return (void *)host->private; 122 + } 123 + 122 124 #define mmc_dev(x) ((x)->dev) 123 125 #define mmc_hostname(x) ((x)->class_dev.class_id) 124 126