smem.c (7d01934455e3f5efc0019befe1b78ebe60dd7b0c) smem.c (13a920ae7898ffa075391ba36b63251f686d38a3)
1/*
2 * Copyright (c) 2015, Sony Mobile Communications AB.
3 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 and
7 * only version 2 as published by the Free Software Foundation.
8 *

--- 806 unchanged lines hidden (view full) ---

815 return -EINVAL;
816
817 smem->global_partition = header;
818 smem->global_cacheline = le32_to_cpu(entry->cacheline);
819
820 return 0;
821}
822
1/*
2 * Copyright (c) 2015, Sony Mobile Communications AB.
3 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 and
7 * only version 2 as published by the Free Software Foundation.
8 *

--- 806 unchanged lines hidden (view full) ---

815 return -EINVAL;
816
817 smem->global_partition = header;
818 smem->global_cacheline = le32_to_cpu(entry->cacheline);
819
820 return 0;
821}
822
823static int qcom_smem_enumerate_partitions(struct qcom_smem *smem,
824 unsigned int local_host)
823static int
824qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host)
825{
826 struct smem_partition_header *header;
827 struct smem_ptable_entry *entry;
828 struct smem_ptable *ptable;
829 unsigned int remote_host;
825{
826 struct smem_partition_header *header;
827 struct smem_ptable_entry *entry;
828 struct smem_ptable *ptable;
829 unsigned int remote_host;
830 u32 host0, host1;
830 u16 host0, host1;
831 int i;
832
833 ptable = qcom_smem_get_ptable(smem);
834 if (IS_ERR(ptable))
835 return PTR_ERR(ptable);
836
837 for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) {
838 entry = &ptable->entry[i];

--- 7 unchanged lines hidden (view full) ---

846 if (host0 == local_host)
847 remote_host = host1;
848 else if (host1 == local_host)
849 remote_host = host0;
850 else
851 continue;
852
853 if (remote_host >= SMEM_HOST_COUNT) {
831 int i;
832
833 ptable = qcom_smem_get_ptable(smem);
834 if (IS_ERR(ptable))
835 return PTR_ERR(ptable);
836
837 for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) {
838 entry = &ptable->entry[i];

--- 7 unchanged lines hidden (view full) ---

846 if (host0 == local_host)
847 remote_host = host1;
848 else if (host1 == local_host)
849 remote_host = host0;
850 else
851 continue;
852
853 if (remote_host >= SMEM_HOST_COUNT) {
854 dev_err(smem->dev,
855 "Invalid remote host %d\n",
856 remote_host);
854 dev_err(smem->dev, "bad host %hu\n", remote_host);
857 return -EINVAL;
858 }
859
860 if (smem->partitions[remote_host]) {
855 return -EINVAL;
856 }
857
858 if (smem->partitions[remote_host]) {
861 dev_err(smem->dev,
862 "Already found a partition for host %d\n",
863 remote_host);
859 dev_err(smem->dev, "duplicate host %hu\n", remote_host);
864 return -EINVAL;
865 }
866
867 header = qcom_smem_partition_header(smem, entry, host0, host1);
868 if (!header)
869 return -EINVAL;
870
871 smem->partitions[remote_host] = header;

--- 80 unchanged lines hidden (view full) ---

952 case SMEM_GLOBAL_HEAP_VERSION:
953 smem->item_count = SMEM_ITEM_COUNT;
954 break;
955 default:
956 dev_err(&pdev->dev, "Unsupported SMEM version 0x%x\n", version);
957 return -EINVAL;
958 }
959
860 return -EINVAL;
861 }
862
863 header = qcom_smem_partition_header(smem, entry, host0, host1);
864 if (!header)
865 return -EINVAL;
866
867 smem->partitions[remote_host] = header;

--- 80 unchanged lines hidden (view full) ---

948 case SMEM_GLOBAL_HEAP_VERSION:
949 smem->item_count = SMEM_ITEM_COUNT;
950 break;
951 default:
952 dev_err(&pdev->dev, "Unsupported SMEM version 0x%x\n", version);
953 return -EINVAL;
954 }
955
956 BUILD_BUG_ON(SMEM_HOST_APPS >= SMEM_HOST_COUNT);
960 ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS);
961 if (ret < 0 && ret != -ENOENT)
962 return ret;
963
964 hwlock_id = of_hwspin_lock_get_id(pdev->dev.of_node, 0);
965 if (hwlock_id < 0) {
966 if (hwlock_id != -EPROBE_DEFER)
967 dev_err(&pdev->dev, "failed to retrieve hwlock\n");

--- 51 unchanged lines hidden ---
957 ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS);
958 if (ret < 0 && ret != -ENOENT)
959 return ret;
960
961 hwlock_id = of_hwspin_lock_get_id(pdev->dev.of_node, 0);
962 if (hwlock_id < 0) {
963 if (hwlock_id != -EPROBE_DEFER)
964 dev_err(&pdev->dev, "failed to retrieve hwlock\n");

--- 51 unchanged lines hidden ---