diff options
author | Suzuki K Poulose <suzuki.poulose@arm.com> | 2016-08-25 15:19:05 -0600 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-08-31 13:05:43 +0200 |
commit | 9486295ad159fac87eb05bd683445be06a3b69f5 (patch) | |
tree | 816579242f76e6481e8900d150391a17e646a438 /drivers/hwtracing/coresight/coresight-stm.c | |
parent | 7f73b0b9faa11446f73dba02811f928a230773c5 (diff) | |
download | blackbird-op-linux-9486295ad159fac87eb05bd683445be06a3b69f5.tar.gz blackbird-op-linux-9486295ad159fac87eb05bd683445be06a3b69f5.zip |
coresight: Use local coresight_desc instances
Each coresight device prepares a description for coresight_register()
in struct coresight_desc. Once we register the device, the description is
useless and can be freed. The coresight_desc is small enough (48bytes on
64bit)i to be allocated on the stack. Hence use an automatic variable to
avoid a needless dynamic allocation and wasting the memory(which will only
be free'd when the device is destroyed).
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Pratik Patel <pratikp@codeaurora.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hwtracing/coresight/coresight-stm.c')
-rw-r--r-- | drivers/hwtracing/coresight/coresight-stm.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 482c8bb27f87..819629aed2f7 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -799,7 +799,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) struct resource *res = &adev->res; struct resource ch_res; size_t res_size, bitmap_size; - struct coresight_desc *desc; + struct coresight_desc desc = { 0 }; struct device_node *np = adev->dev.of_node; if (np) { @@ -865,19 +865,13 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) return -EPROBE_DEFER; } - desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); - if (!desc) { - ret = -ENOMEM; - goto stm_unregister; - } - - desc->type = CORESIGHT_DEV_TYPE_SOURCE; - desc->subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE; - desc->ops = &stm_cs_ops; - desc->pdata = pdata; - desc->dev = dev; - desc->groups = coresight_stm_groups; - drvdata->csdev = coresight_register(desc); + desc.type = CORESIGHT_DEV_TYPE_SOURCE; + desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE; + desc.ops = &stm_cs_ops; + desc.pdata = pdata; + desc.dev = dev; + desc.groups = coresight_stm_groups; + drvdata->csdev = coresight_register(&desc); if (IS_ERR(drvdata->csdev)) { ret = PTR_ERR(drvdata->csdev); goto stm_unregister; |