From: Adrian Hunter Date: Wed, 19 Apr 2017 12:48:55 +0000 (+0300) Subject: mmc: sdhci-pci: Allow for 3 bytes from Intel DSM X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a72016a44703476bdb3567a13695938566e8f413;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git mmc: sdhci-pci: Allow for 3 bytes from Intel DSM The DSM used by some Intel controllers can return a 3 byte package. Allow for that by using memcpy to copy the bytes. Signed-off-by: Adrian Hunter Signed-off-by: Ulf Hansson --- diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c index 833072b8453e..92fc3f7c538d 100644 --- a/drivers/mmc/host/sdhci-pci-core.c +++ b/drivers/mmc/host/sdhci-pci-core.c @@ -12,6 +12,7 @@ * - JMicron (hardware and technical support) */ +#include #include #include #include @@ -413,6 +414,7 @@ static int __intel_dsm(struct intel_host *intel_host, struct device *dev, { union acpi_object *obj; int err = 0; + size_t len; obj = acpi_evaluate_dsm(ACPI_HANDLE(dev), intel_dsm_uuid, 0, fn, NULL); if (!obj) @@ -423,12 +425,10 @@ static int __intel_dsm(struct intel_host *intel_host, struct device *dev, goto out; } - if (obj->buffer.length >= 4) - *result = *(u32 *)obj->buffer.pointer; - else if (obj->buffer.length >= 2) - *result = *(u16 *)obj->buffer.pointer; - else - *result = *(u8 *)obj->buffer.pointer; + len = min_t(size_t, obj->buffer.length, 4); + + *result = 0; + memcpy(result, obj->buffer.pointer, len); out: ACPI_FREE(obj);