On 4/3/25 2:03 PM, Gokul Sriram Palanisamy wrote:
> Introduce a helper to return the machid which is used to identify the
> specific board variant derived from the same SoC.
> 
> Signed-off-by: Gokul Sriram Palanisamy <gokul.srira...@oss.qualcomm.com>
> ---
>  drivers/soc/qcom/smem.c       | 26 ++++++++++++++++++++++++++
>  include/linux/soc/qcom/smem.h |  1 +
>  2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> index 592819701809..327f7358191d 100644
> --- a/drivers/soc/qcom/smem.c
> +++ b/drivers/soc/qcom/smem.c
> @@ -827,6 +827,32 @@ int qcom_smem_get_soc_id(u32 *id)
>  }
>  EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id);
>  
> +/**
> + * qcom_smem_get_machid() - return the machid
> + * @id:      On success, we return the machid here.
> + *
> + * generate machid from HW/SW build ID and return it.
> + *
> + * Return: 0 on success, negative errno on failure.
> + */
> +
> +int qcom_smem_get_machid(u32 *id)
> +{
> +     struct socinfo *info;
> +
> +     info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL);
> +     if (IS_ERR(info))
> +             return PTR_ERR(info);
> +
> +     *id = ((info->hw_plat << 24) |
> +           (((info->plat_ver & 0xffff0000) >> 16) << 16) |
> +           ((info->plat_ver & 0x0000ffff) << 8) |
> +           (info->hw_plat_subtype));

FIELD_PREP + GENMASK, not raw bit ops, please

Is this format specific to this usecase, or is it used more widely?
If the former, it may be better to export these variables separately
and combine them into this specific combination of fields in the
consumer

Konrad

Reply via email to