Re: [PATCH v2 1/8] soc: qcom: Make qcom_smem_get() return a pointer

2015-09-03 Thread Bjorn Andersson
On Wed 02 Sep 15:46 PDT 2015, Stephen Boyd wrote:

> Passing a void ** almost always requires a cast at the call site.
> Instead of littering the code with casts every time this function
> is called, have qcom_smem_get() return a void pointer to the
> location of the smem item. This frees the caller from having to
> cast the pointer.
> 
Reviewed-by: Bjorn Andersson 
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/8] soc: qcom: Make qcom_smem_get() return a pointer

2015-09-02 Thread Stephen Boyd
Passing a void ** almost always requires a cast at the call site.
Instead of littering the code with casts every time this function
is called, have qcom_smem_get() return a void pointer to the
location of the smem item. This frees the caller from having to
cast the pointer.

Cc: Bjorn Andersson 
Signed-off-by: Stephen Boyd 
---

Changes since v1:
 * Moved to before the smem big endian patch

 drivers/soc/qcom/smd.c| 30 +-
 drivers/soc/qcom/smem.c   | 72 +++
 include/linux/soc/qcom/smem.h |  2 +-
 3 files changed, 48 insertions(+), 56 deletions(-)

diff --git a/drivers/soc/qcom/smd.c b/drivers/soc/qcom/smd.c
index edd9d9a37238..aa65c07f281e 100644
--- a/drivers/soc/qcom/smd.c
+++ b/drivers/soc/qcom/smd.c
@@ -978,10 +978,11 @@ static struct qcom_smd_channel 
*qcom_smd_create_channel(struct qcom_smd_edge *ed
spin_lock_init(>recv_lock);
init_waitqueue_head(>fblockread_event);
 
-   ret = qcom_smem_get(edge->remote_pid, smem_info_item, (void **),
-   _size);
-   if (ret)
+   info = qcom_smem_get(edge->remote_pid, smem_info_item, _size);
+   if (IS_ERR(info)) {
+   ret = PTR_ERR(info);
goto free_name_and_channel;
+   }
 
/*
 * Use the size of the item to figure out which channel info struct to
@@ -1000,10 +1001,11 @@ static struct qcom_smd_channel 
*qcom_smd_create_channel(struct qcom_smd_edge *ed
goto free_name_and_channel;
}
 
-   ret = qcom_smem_get(edge->remote_pid, smem_fifo_item, _base,
-   _size);
-   if (ret)
+   fifo_base = qcom_smem_get(edge->remote_pid, smem_fifo_item, _size);
+   if (IS_ERR(fifo_base)) {
+   ret =  PTR_ERR(fifo_base);
goto free_name_and_channel;
+   }
 
/* The channel consist of a rx and tx fifo of equal size */
fifo_size /= 2;
@@ -1040,16 +1042,13 @@ static void qcom_discover_channels(struct qcom_smd_edge 
*edge)
unsigned long flags;
unsigned fifo_id;
unsigned info_id;
-   int ret;
int tbl;
int i;
 
for (tbl = 0; tbl < SMD_ALLOC_TBL_COUNT; tbl++) {
-   ret = qcom_smem_get(edge->remote_pid,
-   smem_items[tbl].alloc_tbl_id,
-   (void **)_tbl,
-   NULL);
-   if (ret < 0)
+   alloc_tbl = qcom_smem_get(edge->remote_pid,
+   smem_items[tbl].alloc_tbl_id, NULL);
+   if (IS_ERR(alloc_tbl))
continue;
 
for (i = 0; i < SMD_ALLOC_TBL_SIZE; i++) {
@@ -1227,11 +1226,12 @@ static int qcom_smd_probe(struct platform_device *pdev)
int num_edges;
int ret;
int i = 0;
+   void *p;
 
/* Wait for smem */
-   ret = qcom_smem_get(QCOM_SMEM_HOST_ANY, smem_items[0].alloc_tbl_id, 
NULL, NULL);
-   if (ret == -EPROBE_DEFER)
-   return ret;
+   p = qcom_smem_get(QCOM_SMEM_HOST_ANY, smem_items[0].alloc_tbl_id, NULL);
+   if (PTR_ERR(p) == -EPROBE_DEFER)
+   return PTR_ERR(p);
 
num_edges = of_get_available_child_count(pdev->dev.of_node);
array_size = sizeof(*smd) + num_edges * sizeof(struct qcom_smd_edge);
diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index f402a606eb7d..e6d0dae63845 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -378,10 +378,9 @@ int qcom_smem_alloc(unsigned host, unsigned item, size_t 
size)
 }
 EXPORT_SYMBOL(qcom_smem_alloc);
 
-static int qcom_smem_get_global(struct qcom_smem *smem,
-   unsigned item,
-   void **ptr,
-   size_t *size)
+static void *qcom_smem_get_global(struct qcom_smem *smem,
+ unsigned item,
+ size_t *size)
 {
struct smem_header *header;
struct smem_region *area;
@@ -390,36 +389,32 @@ static int qcom_smem_get_global(struct qcom_smem *smem,
unsigned i;
 
if (WARN_ON(item >= SMEM_ITEM_COUNT))
-   return -EINVAL;
+   return ERR_PTR(-EINVAL);
 
header = smem->regions[0].virt_base;
entry = >toc[item];
if (!entry->allocated)
-   return -ENXIO;
+   return ERR_PTR(-ENXIO);
 
-   if (ptr != NULL) {
-   aux_base = entry->aux_base & AUX_BASE_MASK;
+   aux_base = entry->aux_base & AUX_BASE_MASK;
 
-   for (i = 0; i < smem->num_regions; i++) {
-   area = >regions[i];
+   for (i = 0; i < smem->num_regions; i++) {
+   area = >regions[i];
 
-   if (area->aux_base == aux_base || !aux_base) {
-   *ptr =