drm/amd: cleanup get_mfd_cell_dev()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 25 Feb 2016 07:47:10 +0000 (10:47 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 26 Feb 2016 17:43:47 +0000 (12:43 -0500)
It's simpler to just use snprintf() to print this to one buffer instead
of using strcpy() and strcat().  Also using snprintf() is slightly safer
than using sprintf().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c

index 9f8cfaab30040b2f3bcc051d3b051055b1094477..d6b0bff510aaa719dbb0f9cce269645b06716127 100644 (file)
@@ -240,12 +240,10 @@ static int acp_poweron(struct generic_pm_domain *genpd)
 static struct device *get_mfd_cell_dev(const char *device_name, int r)
 {
        char auto_dev_name[25];
-       char buf[8];
        struct device *dev;
 
-       sprintf(buf, ".%d.auto", r);
-       strcpy(auto_dev_name, device_name);
-       strcat(auto_dev_name, buf);
+       snprintf(auto_dev_name, sizeof(auto_dev_name),
+                "%s.%d.auto", device_name, r);
        dev = bus_find_device_by_name(&platform_bus_type, NULL, auto_dev_name);
        dev_info(dev, "device %s added to pm domain\n", auto_dev_name);