Skip to content

Commit

Permalink
mmc: sdhci-pci: Allow for 3 bytes from Intel DSM
Browse files Browse the repository at this point in the history
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 <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
  • Loading branch information
Adrian Hunter authored and Ulf Hansson committed Apr 24, 2017
1 parent 3fcc783 commit a72016a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/mmc/host/sdhci-pci-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* - JMicron (hardware and technical support)
*/

#include <linux/string.h>
#include <linux/delay.h>
#include <linux/highmem.h>
#include <linux/module.h>
Expand Down Expand Up @@ -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)
Expand All @@ -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);

Expand Down

0 comments on commit a72016a

Please sign in to comment.