From: Naresh Bhat naresh.bhat@linaro.org
Remove duplicate code acpi_dsm_lookup_value is moved to acpi_keyvalue.c file.
Signed-off-by: Naresh Bhat naresh.bhat@linaro.org --- drivers/amba/acpi.c | 100 ++------------------------------------------------- 1 file changed, 2 insertions(+), 98 deletions(-)
diff --git a/drivers/amba/acpi.c b/drivers/amba/acpi.c index 9a97cd8..abf4cd4 100644 --- a/drivers/amba/acpi.c +++ b/drivers/amba/acpi.c @@ -25,102 +25,6 @@ struct acpi_amba_bus_info { char *clk_name; };
-/* UUID: a706b112-bf0b-48d2-9fa3-95591a3c4c06 (randomly generated) */ -static const char acpi_amba_dsm_uuid[] = { - 0xa7, 0x06, 0xb1, 0x12, 0xbf, 0x0b, 0x48, 0xd2, - 0x9f, 0xa3, 0x95, 0x59, 0x1a, 0x3c, 0x4c, 0x06 -}; - -/* acpi_amba_dsm_lookup() - * - * Helper to parse through ACPI _DSM object for a device. Each entry - * has three fields. - */ -int acpi_amba_dsm_lookup(acpi_handle handle, - const char *tag, int index, - struct acpi_amba_dsm_entry *entry) -{ - acpi_status status; - struct acpi_object_list input; - struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object params[4]; - union acpi_object *obj; - int len, match_count, i; - - /* invalidate output in case there's no entry to supply */ - entry->key = NULL; - entry->value = NULL; - - if (!acpi_has_method(handle, "_DSM")) - return -ENOENT; - - input.count = 4; - params[0].type = ACPI_TYPE_BUFFER; /* UUID */ - params[0].buffer.length = sizeof(acpi_amba_dsm_uuid); - params[0].buffer.pointer = (char *)acpi_amba_dsm_uuid; - params[1].type = ACPI_TYPE_INTEGER; /* Revision */ - params[1].integer.value = 1; - params[2].type = ACPI_TYPE_INTEGER; /* Function # */ - params[2].integer.value = 1; - params[3].type = ACPI_TYPE_PACKAGE; /* Arguments */ - params[3].package.count = 0; - params[3].package.elements = NULL; - input.pointer = params; - - status = acpi_evaluate_object_typed(handle, "_DSM", - &input, &output, ACPI_TYPE_PACKAGE); - if (ACPI_FAILURE(status)) { - pr_err("failed to get _DSM package for this device\n"); - return -ENOENT; - } - - obj = (union acpi_object *)output.pointer; - - /* parse 2 objects per entry */ - match_count = 0; - for (i = 0; (i + 2) <= obj->package.count; i += 2) { - /* key must be a string */ - len = obj->package.elements[i].string.length; - if (len <= 0) - continue; - - /* check to see if this is the entry to return */ - if (strncmp(tag, obj->package.elements[i].string.pointer, - len) != 0 || - match_count < index) { - match_count++; - continue; - } - - /* copy the key */ - entry->key = kmalloc(len + 1, GFP_KERNEL); - strncpy(entry->key, - obj->package.elements[i].string.pointer, - len); - entry->key[len] = '\0'; - - /* value is a string with space-delimited fields if necessary */ - len = obj->package.elements[i + 1].string.length; - if (len > 0) { - entry->value = kmalloc(len + 1, GFP_KERNEL); - strncpy(entry->value, - obj->package.elements[i+1].string.pointer, - len); - entry->value[len] = '\0'; - } - - break; - } - - kfree(output.pointer); - - if (entry->key == NULL) - return -ENOENT; - - return 0; -} -EXPORT_SYMBOL_GPL(acpi_amba_dsm_lookup); - static int acpi_amba_add_resource(struct acpi_resource *ares, void *data) { struct amba_device *dev = data; @@ -157,7 +61,7 @@ static int acpi_amba_add_resource(struct acpi_resource *ares, void *data) static struct clk *acpi_amba_get_clk(acpi_handle handle, int index, char **clk_name) { - struct acpi_amba_dsm_entry entry; + struct acpi_dsm_entry entry; acpi_handle clk_handle; struct acpi_device *adev, *clk_adev; char *clk_path; @@ -172,7 +76,7 @@ static struct clk *acpi_amba_get_clk(acpi_handle handle, int index, /* key=value format for clocks is: * "clock-name"="apb_pclk \_SB.CLK0" */ - if (acpi_amba_dsm_lookup(handle, "clock-name", index, &entry) != 0) + if (acpi_dsm_lookup_value(handle, "clock-name", index, &entry) != 0) return NULL;
/* look under the clock device for the clock that matches the entry */
Hi Naresh,
Patch looks good to me feel free to push it to your acpi-drivers branch.
If you want to test your git prowess you could actually rebase and squash it into the commit that add amba bus.
Just make sure the commit that creates acpi_keyvalue.c comes first.
Graeme
On Fri, Feb 21, 2014 at 06:47:35PM +0530, naresh.bhat@linaro.org wrote:
From: Naresh Bhat naresh.bhat@linaro.org
Remove duplicate code acpi_dsm_lookup_value is moved to acpi_keyvalue.c file.
Signed-off-by: Naresh Bhat naresh.bhat@linaro.org
drivers/amba/acpi.c | 100 ++------------------------------------------------- 1 file changed, 2 insertions(+), 98 deletions(-)
diff --git a/drivers/amba/acpi.c b/drivers/amba/acpi.c index 9a97cd8..abf4cd4 100644 --- a/drivers/amba/acpi.c +++ b/drivers/amba/acpi.c @@ -25,102 +25,6 @@ struct acpi_amba_bus_info { char *clk_name; }; -/* UUID: a706b112-bf0b-48d2-9fa3-95591a3c4c06 (randomly generated) */ -static const char acpi_amba_dsm_uuid[] = {
- 0xa7, 0x06, 0xb1, 0x12, 0xbf, 0x0b, 0x48, 0xd2,
- 0x9f, 0xa3, 0x95, 0x59, 0x1a, 0x3c, 0x4c, 0x06
-};
-/* acpi_amba_dsm_lookup()
- Helper to parse through ACPI _DSM object for a device. Each entry
- has three fields.
- */
-int acpi_amba_dsm_lookup(acpi_handle handle,
const char *tag, int index,
struct acpi_amba_dsm_entry *entry)
-{
- acpi_status status;
- struct acpi_object_list input;
- struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
- union acpi_object params[4];
- union acpi_object *obj;
- int len, match_count, i;
- /* invalidate output in case there's no entry to supply */
- entry->key = NULL;
- entry->value = NULL;
- if (!acpi_has_method(handle, "_DSM"))
return -ENOENT;
- input.count = 4;
- params[0].type = ACPI_TYPE_BUFFER; /* UUID */
- params[0].buffer.length = sizeof(acpi_amba_dsm_uuid);
- params[0].buffer.pointer = (char *)acpi_amba_dsm_uuid;
- params[1].type = ACPI_TYPE_INTEGER; /* Revision */
- params[1].integer.value = 1;
- params[2].type = ACPI_TYPE_INTEGER; /* Function # */
- params[2].integer.value = 1;
- params[3].type = ACPI_TYPE_PACKAGE; /* Arguments */
- params[3].package.count = 0;
- params[3].package.elements = NULL;
- input.pointer = params;
- status = acpi_evaluate_object_typed(handle, "_DSM",
&input, &output, ACPI_TYPE_PACKAGE);
- if (ACPI_FAILURE(status)) {
pr_err("failed to get _DSM package for this device\n");
return -ENOENT;
- }
- obj = (union acpi_object *)output.pointer;
- /* parse 2 objects per entry */
- match_count = 0;
- for (i = 0; (i + 2) <= obj->package.count; i += 2) {
/* key must be a string */
len = obj->package.elements[i].string.length;
if (len <= 0)
continue;
/* check to see if this is the entry to return */
if (strncmp(tag, obj->package.elements[i].string.pointer,
len) != 0 ||
match_count < index) {
match_count++;
continue;
}
/* copy the key */
entry->key = kmalloc(len + 1, GFP_KERNEL);
strncpy(entry->key,
obj->package.elements[i].string.pointer,
len);
entry->key[len] = '\0';
/* value is a string with space-delimited fields if necessary */
len = obj->package.elements[i + 1].string.length;
if (len > 0) {
entry->value = kmalloc(len + 1, GFP_KERNEL);
strncpy(entry->value,
obj->package.elements[i+1].string.pointer,
len);
entry->value[len] = '\0';
}
break;
- }
- kfree(output.pointer);
- if (entry->key == NULL)
return -ENOENT;
- return 0;
-} -EXPORT_SYMBOL_GPL(acpi_amba_dsm_lookup);
static int acpi_amba_add_resource(struct acpi_resource *ares, void *data) { struct amba_device *dev = data; @@ -157,7 +61,7 @@ static int acpi_amba_add_resource(struct acpi_resource *ares, void *data) static struct clk *acpi_amba_get_clk(acpi_handle handle, int index, char **clk_name) {
- struct acpi_amba_dsm_entry entry;
- struct acpi_dsm_entry entry; acpi_handle clk_handle; struct acpi_device *adev, *clk_adev; char *clk_path;
@@ -172,7 +76,7 @@ static struct clk *acpi_amba_get_clk(acpi_handle handle, int index, /* key=value format for clocks is: * "clock-name"="apb_pclk \_SB.CLK0" */
- if (acpi_amba_dsm_lookup(handle, "clock-name", index, &entry) != 0)
- if (acpi_dsm_lookup_value(handle, "clock-name", index, &entry) != 0) return NULL;
/* look under the clock device for the clock that matches the entry */ -- 1.7.9.5
Linaro-acpi mailing list Linaro-acpi@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-acpi
Hi Graeme,
Thanks.
Sure, I will work on that.
Regards -Naresh
On 21 February 2014 19:11, Graeme Gregory graeme.gregory@linaro.org wrote:
Hi Naresh,
Patch looks good to me feel free to push it to your acpi-drivers branch.
If you want to test your git prowess you could actually rebase and squash it into the commit that add amba bus.
Just make sure the commit that creates acpi_keyvalue.c comes first.
Graeme
On Fri, Feb 21, 2014 at 06:47:35PM +0530, naresh.bhat@linaro.org wrote:
From: Naresh Bhat naresh.bhat@linaro.org
Remove duplicate code acpi_dsm_lookup_value is moved to acpi_keyvalue.c
file.
Signed-off-by: Naresh Bhat naresh.bhat@linaro.org
drivers/amba/acpi.c | 100
++-------------------------------------------------
1 file changed, 2 insertions(+), 98 deletions(-)
diff --git a/drivers/amba/acpi.c b/drivers/amba/acpi.c index 9a97cd8..abf4cd4 100644 --- a/drivers/amba/acpi.c +++ b/drivers/amba/acpi.c @@ -25,102 +25,6 @@ struct acpi_amba_bus_info { char *clk_name; };
-/* UUID: a706b112-bf0b-48d2-9fa3-95591a3c4c06 (randomly generated) */ -static const char acpi_amba_dsm_uuid[] = {
0xa7, 0x06, 0xb1, 0x12, 0xbf, 0x0b, 0x48, 0xd2,
0x9f, 0xa3, 0x95, 0x59, 0x1a, 0x3c, 0x4c, 0x06
-};
-/* acpi_amba_dsm_lookup()
- Helper to parse through ACPI _DSM object for a device. Each entry
- has three fields.
- */
-int acpi_amba_dsm_lookup(acpi_handle handle,
const char *tag, int index,
struct acpi_amba_dsm_entry *entry)
-{
acpi_status status;
struct acpi_object_list input;
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object params[4];
union acpi_object *obj;
int len, match_count, i;
/* invalidate output in case there's no entry to supply */
entry->key = NULL;
entry->value = NULL;
if (!acpi_has_method(handle, "_DSM"))
return -ENOENT;
input.count = 4;
params[0].type = ACPI_TYPE_BUFFER; /* UUID */
params[0].buffer.length = sizeof(acpi_amba_dsm_uuid);
params[0].buffer.pointer = (char *)acpi_amba_dsm_uuid;
params[1].type = ACPI_TYPE_INTEGER; /* Revision */
params[1].integer.value = 1;
params[2].type = ACPI_TYPE_INTEGER; /* Function # */
params[2].integer.value = 1;
params[3].type = ACPI_TYPE_PACKAGE; /* Arguments */
params[3].package.count = 0;
params[3].package.elements = NULL;
input.pointer = params;
status = acpi_evaluate_object_typed(handle, "_DSM",
&input, &output, ACPI_TYPE_PACKAGE);
if (ACPI_FAILURE(status)) {
pr_err("failed to get _DSM package for this device\n");
return -ENOENT;
}
obj = (union acpi_object *)output.pointer;
/* parse 2 objects per entry */
match_count = 0;
for (i = 0; (i + 2) <= obj->package.count; i += 2) {
/* key must be a string */
len = obj->package.elements[i].string.length;
if (len <= 0)
continue;
/* check to see if this is the entry to return */
if (strncmp(tag, obj->package.elements[i].string.pointer,
len) != 0 ||
match_count < index) {
match_count++;
continue;
}
/* copy the key */
entry->key = kmalloc(len + 1, GFP_KERNEL);
strncpy(entry->key,
obj->package.elements[i].string.pointer,
len);
entry->key[len] = '\0';
/* value is a string with space-delimited fields if
necessary */
len = obj->package.elements[i + 1].string.length;
if (len > 0) {
entry->value = kmalloc(len + 1, GFP_KERNEL);
strncpy(entry->value,
obj->package.elements[i+1].string.pointer,
len);
entry->value[len] = '\0';
}
break;
}
kfree(output.pointer);
if (entry->key == NULL)
return -ENOENT;
return 0;
-} -EXPORT_SYMBOL_GPL(acpi_amba_dsm_lookup);
static int acpi_amba_add_resource(struct acpi_resource *ares, void
*data)
{ struct amba_device *dev = data; @@ -157,7 +61,7 @@ static int acpi_amba_add_resource(struct
acpi_resource *ares, void *data)
static struct clk *acpi_amba_get_clk(acpi_handle handle, int index, char **clk_name) {
struct acpi_amba_dsm_entry entry;
struct acpi_dsm_entry entry; acpi_handle clk_handle; struct acpi_device *adev, *clk_adev; char *clk_path;
@@ -172,7 +76,7 @@ static struct clk *acpi_amba_get_clk(acpi_handle
handle, int index,
/* key=value format for clocks is: * "clock-name"="apb_pclk \\_SB.CLK0" */
if (acpi_amba_dsm_lookup(handle, "clock-name", index, &entry) != 0)
if (acpi_dsm_lookup_value(handle, "clock-name", index, &entry) !=
return NULL; /* look under the clock device for the clock that matches the
entry */
-- 1.7.9.5
Linaro-acpi mailing list Linaro-acpi@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-acpi