mfd: ssbi: removing unnecessary strcmp
PATCH 1/1 mfd: ssbi: removing unnecessary strcmp
passing the actual enum value for controller type from device tree, instead of passing the string and converting it to enum
Signed-off-by Saurabh Sengar <[email protected]>
--- Documentation/devicetree/bindings/arm/msm/ssbi.txt | 6 +++--- arch/arm/boot/dts/qcom-apq8064.dtsi | 3 ++- arch/arm/boot/dts/qcom-ipq8064.dtsi | 3 ++- arch/arm/boot/dts/qcom-msm8660.dtsi | 3 ++- arch/arm/boot/dts/qcom-msm8960.dtsi | 3 ++- drivers/mfd/ssbi.c | 17 ++++++----------- include/dt-bindings/mfd/qcom,ssbi.h | 19 +++++++++++++++++++ 7 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 include/dt-bindings/mfd/qcom,ssbi.h
Documentation/devicetree/bindings/arm/msm/ssbi.txt +3 -3
@@ -10,9 +10,9 @@ These require the following properties: - qcom,controller-type indicates the SSBI bus variant the controller should use to talk - with the slave device. This should be one of "ssbi", "ssbi2", or - "pmic-arbiter". The type chosen is determined by the attached - slave. + with the slave device. This should be one of MSM_SBI_CTRL_SSBI, + MSM_SBI_CTRL_SSBI2 or MSM_SBI_CTRL_PMIC_ARBITER. + The type chosen is determined by the attached slave. The slave device should be the single child node of the ssbi device with a compatible field.
arch/arm/boot/dts/qcom-apq8064.dtsi +2 -1
@@ -5,6 +5,7 @@ #include <dt-bindings/reset/qcom,gcc-msm8960.h> #include <dt-bindings/clock/qcom,mmcc-msm8960.h> #include <dt-bindings/soc/qcom,gsbi.h> +#include <dt-bindings/mfd/qcom,ssbi.h> #include <dt-bindings/interrupt-controller/arm-gic.h> / { model = "Qualcomm APQ8064";
@@ -339,7 +340,7 @@ qcom,ssbi@500000 { compatible = "qcom,ssbi"; reg = <0x00500000 0x1000>; - qcom,controller-type = "pmic-arbiter"; + qcom,controller-type = <MSM_SBI_CTRL_PMIC_ARBITER>; pmicintc: pmic@0 { compatible = "qcom,pm8921";
arch/arm/boot/dts/qcom-ipq8064.dtsi +2 -1
@@ -3,6 +3,7 @@ #include "skeleton.dtsi" #include <dt-bindings/clock/qcom,gcc-ipq806x.h> #include <dt-bindings/clock/qcom,lcc-ipq806x.h> +#include <dt-bindings/mfd/qcom,ssbi.h> #include <dt-bindings/soc/qcom,gsbi.h> / {
@@ -307,7 +308,7 @@ qcom,ssbi@500000 { compatible = "qcom,ssbi"; reg = <0x00500000 0x1000>; - qcom,controller-type = "pmic-arbiter"; + qcom,controller-type = <MSM_SBI_CTRL_PMIC_ARBITER>; }; gcc: clock-controller@900000 {
arch/arm/boot/dts/qcom-msm8660.dtsi +2 -1
@@ -4,6 +4,7 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/qcom,gcc-msm8660.h> +#include <dt-bindings/mfd/qcom,ssbi.h> #include <dt-bindings/soc/qcom,gsbi.h> / {
@@ -112,7 +113,7 @@ qcom,ssbi@500000 { compatible = "qcom,ssbi"; reg = <0x500000 0x1000>; - qcom,controller-type = "pmic-arbiter"; + qcom,controller-type = <MSM_SBI_CTRL_PMIC_ARBITER>; pmicintc: pmic@0 { compatible = "qcom,pm8058";
arch/arm/boot/dts/qcom-msm8960.dtsi +2 -1
@@ -5,6 +5,7 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/qcom,gcc-msm8960.h> #include <dt-bindings/mfd/qcom-rpm.h> +#include <dt-bindings/mfd/qcom,ssbi.h> #include <dt-bindings/soc/qcom,gsbi.h> / {
@@ -171,7 +172,7 @@ qcom,ssbi@500000 { compatible = "qcom,ssbi"; reg = <0x500000 0x1000>; - qcom,controller-type = "pmic-arbiter"; + qcom,controller-type = <MSM_SBI_CTRL_PMIC_ARBITER>; pmicintc: pmic@0 { compatible = "qcom,pm8921";
drivers/mfd/ssbi.c +6 -11
@@ -274,7 +274,7 @@ static int ssbi_probe(struct platform_device *pdev)struct device_node *np = pdev->dev.of_node;struct resource *mem_res;struct ssbi *ssbi; -const char *type; +u32 type; ssbi =devm_kzalloc (&pdev->dev,sizeof (*ssbi),GFP_KERNEL );if (!ssbi)
@@ -287,22 +287,17 @@ static int ssbi_probe(struct platform_device *pdev)platform_set_drvdata (pdev, ssbi); - type =of_get_property (np,"qcom,controller-type" ,NULL ); -if (type ==NULL ) { +if (of_property_read_u32 (np,"qcom,controller-type" , &type)) {dev_err (&pdev->dev,"Missing qcom,controller-type property\n" );return -EINVAL ; } -dev_info (&pdev->dev,"SSBI controller type: '%s'\n" , type); -if (strcmp (type,"ssbi" ) ==0 ) - ssbi->controller_type =MSM_SBI_CTRL_SSBI ; -else if (strcmp (type,"ssbi2" ) ==0 ) - ssbi->controller_type =MSM_SBI_CTRL_SSBI2 ; -else if (strcmp (type,"pmic-arbiter" ) ==0 ) - ssbi->controller_type =MSM_SBI_CTRL_PMIC_ARBITER ; -else { + +dev_info (&pdev->dev,"SSBI controller type: '%d'\n" , type); +if (type >MSM_SBI_CTRL_PMIC_ARBITER ) {dev_err (&pdev->dev,"Unknown qcom,controller-type\n" );return -EINVAL ; } + ssbi->controller_type = type;if (ssbi->controller_type ==MSM_SBI_CTRL_PMIC_ARBITER ) { ssbi->read = ssbi_pa_read_bytes;
include/dt-bindings/mfd/qcom,ssbi.h new file +19 -0
@@ -0,0 +1,19 @@ +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#ifndef __DT_MFD_QCOM_SSBI_H +#define __DT_MFD_QCOM_SSBI_H + +#define MSM_SBI_CTRL_SSBI 0 +#define MSM_SBI_CTRL_SSBI2 1 +#define MSM_SBI_CTRL_PMIC_ARBITER 2 + +#endif
Signature · 1 line
1.9.1
Quoted 2 lines · Saurabh Sengar
passing the actual enum value for controller type from device tree, instead of passing the string and converting it to enum
Initially I would have probably preferred this version, but I can't think of a good enough reason to break the current ABI in order to replace it.
Quoted 179 lines
Signed-off-by Saurabh Sengar <[email protected]>--- Documentation/devicetree/bindings/arm/msm/ssbi.txt | 6 +++--- arch/arm/boot/dts/qcom-apq8064.dtsi | 3 ++- arch/arm/boot/dts/qcom-ipq8064.dtsi | 3 ++- arch/arm/boot/dts/qcom-msm8660.dtsi | 3 ++- arch/arm/boot/dts/qcom-msm8960.dtsi | 3 ++- drivers/mfd/ssbi.c | 17 ++++++----------- include/dt-bindings/mfd/qcom,ssbi.h | 19 +++++++++++++++++++ 7 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 include/dt-bindings/mfd/qcom,ssbi.hDocumentation/devicetree/bindings/arm/msm/ssbi.txt +3
-3@@ -10,9 +10,9 @@ These require the following properties: - qcom,controller-type indicates the SSBI bus variant the controller should use to talk - with the slave device. This should be one of "ssbi", "ssbi2", or - "pmic-arbiter". The type chosen is determined by the attached - slave. + with the slave device. This should be one of MSM_SBI_CTRL_SSBI, + MSM_SBI_CTRL_SSBI2 or MSM_SBI_CTRL_PMIC_ARBITER. + The type chosen is determined by the attached slave. The slave device should be the single child node of the ssbi device with a compatible field.arch/arm/boot/dts/qcom-apq8064.dtsi +2
-1@@ -5,6 +5,7 @@ #include <dt-bindings/reset/qcom,gcc-msm8960.h> #include <dt-bindings/clock/qcom,mmcc-msm8960.h> #include <dt-bindings/soc/qcom,gsbi.h> +#include <dt-bindings/mfd/qcom,ssbi.h> #include <dt-bindings/interrupt-controller/arm-gic.h> / { model = "Qualcomm APQ8064";@@ -339,7 +340,7 @@ qcom,ssbi@500000 { compatible = "qcom,ssbi"; reg = <0x00500000 0x1000>; - qcom,controller-type = "pmic-arbiter"; + qcom,controller-type = <MSM_SBI_CTRL_PMIC_ARBITER>; pmicintc: pmic@0 { compatible = "qcom,pm8921";arch/arm/boot/dts/qcom-ipq8064.dtsi +2
-1@@ -3,6 +3,7 @@ #include "skeleton.dtsi" #include <dt-bindings/clock/qcom,gcc-ipq806x.h> #include <dt-bindings/clock/qcom,lcc-ipq806x.h> +#include <dt-bindings/mfd/qcom,ssbi.h> #include <dt-bindings/soc/qcom,gsbi.h> / {@@ -307,7 +308,7 @@ qcom,ssbi@500000 { compatible = "qcom,ssbi"; reg = <0x00500000 0x1000>; - qcom,controller-type = "pmic-arbiter"; + qcom,controller-type = <MSM_SBI_CTRL_PMIC_ARBITER>; }; gcc: clock-controller@900000 {arch/arm/boot/dts/qcom-msm8660.dtsi +2
-1@@ -4,6 +4,7 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/qcom,gcc-msm8660.h> +#include <dt-bindings/mfd/qcom,ssbi.h> #include <dt-bindings/soc/qcom,gsbi.h> / {@@ -112,7 +113,7 @@ qcom,ssbi@500000 { compatible = "qcom,ssbi"; reg = <0x500000 0x1000>; - qcom,controller-type = "pmic-arbiter"; + qcom,controller-type = <MSM_SBI_CTRL_PMIC_ARBITER>; pmicintc: pmic@0 { compatible = "qcom,pm8058";arch/arm/boot/dts/qcom-msm8960.dtsi +2
-1@@ -5,6 +5,7 @@ #include <dt-bindings/interrupt-controller/arm-gic.h> #include <dt-bindings/clock/qcom,gcc-msm8960.h> #include <dt-bindings/mfd/qcom-rpm.h> +#include <dt-bindings/mfd/qcom,ssbi.h> #include <dt-bindings/soc/qcom,gsbi.h> / {@@ -171,7 +172,7 @@ qcom,ssbi@500000 { compatible = "qcom,ssbi"; reg = <0x500000 0x1000>; - qcom,controller-type = "pmic-arbiter"; + qcom,controller-type = <MSM_SBI_CTRL_PMIC_ARBITER>; pmicintc: pmic@0 { compatible = "qcom,pm8921";drivers/mfd/ssbi.c +6
-11@@ -274,7 +274,7 @@ static int ssbi_probe(struct platform_device *pdev)struct device_node *np = pdev->dev.of_node;struct resource *mem_res;struct ssbi *ssbi; -const char *type; +u32 type; ssbi =devm_kzalloc (&pdev->dev,sizeof (*ssbi),GFP_KERNEL );if (!ssbi)@@ -287,22 +287,17 @@ static int ssbi_probe(struct platform_device *pdev)platform_set_drvdata (pdev, ssbi); - type =of_get_property (np,"qcom,controller-type" ,NULL ); -if (type ==NULL ) { +if (of_property_read_u32 (np,"qcom,controller-type" , &type)) {dev_err (&pdev->dev,"Missing qcom,controller-type property\n" );return -EINVAL ; } -dev_info (&pdev->dev,"SSBI controller type: '%s'\n" , type); -if (strcmp (type,"ssbi" ) ==0 ) - ssbi->controller_type =MSM_SBI_CTRL_SSBI ; -else if (strcmp (type,"ssbi2" ) ==0 ) - ssbi->controller_type =MSM_SBI_CTRL_SSBI2 ; -else if (strcmp (type,"pmic-arbiter" ) ==0 ) - ssbi->controller_type =MSM_SBI_CTRL_PMIC_ARBITER ; -else { + +dev_info (&pdev->dev,"SSBI controller type: '%d'\n" , type); +if (type >MSM_SBI_CTRL_PMIC_ARBITER ) {dev_err (&pdev->dev,"Unknown qcom,controller-type\n" );return -EINVAL ; } + ssbi->controller_type = type;if (ssbi->controller_type ==MSM_SBI_CTRL_PMIC_ARBITER ) { ssbi->read = ssbi_pa_read_bytes;include/dt-bindings/mfd/qcom,ssbi.h new file +19
-0@@ -0,0 +1,19 @@ +/* Copyright (c) 2015, The Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#ifndef __DT_MFD_QCOM_SSBI_H +#define __DT_MFD_QCOM_SSBI_H + +#define MSM_SBI_CTRL_SSBI 0 +#define MSM_SBI_CTRL_SSBI2 1 +#define MSM_SBI_CTRL_PMIC_ARBITER 2 + +#endif
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog