Commit 1fbd9029 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Rafael J. Wysocki
Browse files

ACPI: property: Refactor acpi_data_prop_read_single()



Refactor acpi_data_prop_read_single() for decreased indentation
and better structure. No functional changes intended.

Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 197b6b60
Loading
Loading
Loading
Loading
+34 −46
Original line number Diff line number Diff line
@@ -971,10 +971,12 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
				      enum dev_prop_type proptype, void *val)
{
	const union acpi_object *obj;
	int ret;
	int ret = 0;

	if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) {
	if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64)
		ret = acpi_data_get_property(data, propname, ACPI_TYPE_INTEGER, &obj);
	else if (proptype == DEV_PROP_STRING)
		ret = acpi_data_get_property(data, propname, ACPI_TYPE_STRING, &obj);
	if (ret)
		return ret;

@@ -982,49 +984,35 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data,
	case DEV_PROP_U8:
		if (obj->integer.value > U8_MAX)
			return -EOVERFLOW;

		if (val)
			*(u8 *)val = obj->integer.value;

		break;
	case DEV_PROP_U16:
		if (obj->integer.value > U16_MAX)
			return -EOVERFLOW;

		if (val)
			*(u16 *)val = obj->integer.value;

		break;
	case DEV_PROP_U32:
		if (obj->integer.value > U32_MAX)
			return -EOVERFLOW;

		if (val)
			*(u32 *)val = obj->integer.value;

		break;
		default:
	case DEV_PROP_U64:
		if (val)
			*(u64 *)val = obj->integer.value;

		break;
		}

		if (!val)
			return 1;
	} else if (proptype == DEV_PROP_STRING) {
		ret = acpi_data_get_property(data, propname, ACPI_TYPE_STRING, &obj);
		if (ret)
			return ret;

	case DEV_PROP_STRING:
		if (val)
			*(char **)val = obj->string.pointer;

		return 1;
	} else {
		ret = -EINVAL;
	default:
		return -EINVAL;
	}
	return ret;

	/* When no storage provided return number of available values */
	return val ? 0 : 1;
}

#define acpi_copy_property_array_uint(items, val, nval)			\