mfd: intel_soc_pmic_bxtwc: Don't shadow error codes in show()/store()
PATCH 1/11 mfd: intel_soc_pmic_bxtwc: Don't shadow error codes in show()/store()
kstrtox() along with regmap API can return different error codes based on circumstances.
Don't shadow them when returning to the caller.
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +9 -5
@@ -339,10 +339,14 @@ static ssize_t addr_show(struct device *dev,static ssize_t addr_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -if (kstrtoul (buf,0 , &bxtwc_reg_addr)) { +int ret; + + ret =kstrtoul (buf,0 , &bxtwc_reg_addr); +if (ret) {dev_err (dev,"Invalid register address\n" ); -return -EINVAL ; +return ret; } +return (ssize_t )count; }
@@ -354,9 +358,9 @@ static ssize_t val_show(struct device *dev,struct intel_soc_pmic *pmic =dev_get_drvdata (dev); ret =regmap_read (pmic->regmap, bxtwc_reg_addr, &val); -if (ret <0 ) { +if (ret) {dev_err (dev,"Failed to read 0x%lx\n" , bxtwc_reg_addr); -return -EIO ; +return ret; }return sprintf (buf,"0x%02x\n" , val);
@@ -377,7 +381,7 @@ static ssize_t val_store(struct device *dev,if (ret) {dev_err (dev,"Failed to write value 0x%02x to address 0x%lx" , val, bxtwc_reg_addr); -return -EIO ; +return ret; }return count; }
Signature · 1 line
2.35.1
PATCH 2/11 mfd: intel_soc_pmic_bxtwc: Create sysfs attributes using core driver's facility
Driver core takes care of sysfs attributes. Use this facility instead of doing it explicitly in ->probe() and ->remove().
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +7 -16
@@ -398,6 +398,11 @@ static const struct attribute_group bxtwc_group = { .attrs = bxtwc_attrs, }; +static const struct attribute_group *bxtwc_groups[] = { + &bxtwc_group, +NULL +}; +static const struct regmap_config bxtwc_regmap_config = { .reg_bits =16 , .val_bits =8 ,
@@ -557,12 +562,6 @@ static int bxtwc_probe(struct platform_device *pdev)return ret; } - ret =sysfs_create_group (&pdev->dev.kobj, &bxtwc_group); -if (ret) { -dev_err (&pdev->dev,"Failed to create sysfs group %d\n" , ret); -return ret; - } -/* * There is known hw bug. Upon reset BIT 5 of register * BXTWC_CHGR_LVL1_IRQ is 0 which is the expected value. However,
@@ -570,15 +569,7 @@ static int bxtwc_probe(struct platform_device *pdev)* have the software workaround here to unmaksed it in order to let * charger interrutp work. */ -regmap_update_bits (pmic->regmap,BXTWC_MIRQLVL1 , -BXTWC_MIRQLVL1_MCHGR ,0 ); - -return 0 ; -} - -static int bxtwc_remove (struct platform_device *pdev) -{ -sysfs_remove_group (&pdev->dev.kobj, &bxtwc_group); +regmap_update_bits (pmic->regmap,BXTWC_MIRQLVL1 ,BXTWC_MIRQLVL1_MCHGR ,0 );return 0 ; }
@@ -618,12 +609,12 @@ MODULE_DEVICE_TABLE(acpi, bxtwc_acpi_ids);static struct platform_driver bxtwc_driver = { .probe = bxtwc_probe, - .remove = bxtwc_remove, .shutdown = bxtwc_shutdown, .driver = { .name ="BXTWC PMIC" , .pm = &bxtwc_pm_ops, .acpi_match_table =ACPI_PTR (bxtwc_acpi_ids), + .dev_groups = bxtwc_groups, }, };
Signature · 1 line
2.35.1
Re: [PATCH v1 02/11] mfd: intel_soc_pmic_bxtwc: Create sysfs attributes using core driver's facility
Quoted 7 lines · Andy Shevchenko
Driver core takes care of sysfs attributes. Use this facility instead of doing it explicitly in ->probe() and ->remove().
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 3/11 mfd: intel_soc_pmic_bxtwc: Convert to use platform_get/set_drvdata()
In reply to Andy ShevchenkoWe have the specific helpers for platform device to set and get its driver data. Convert driver to use them instead of open coded variants.
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +2 -2
@@ -459,7 +459,7 @@ static int bxtwc_probe(struct platform_device *pdev)return ret; pmic->irq = ret; -dev_set_drvdata (&pdev->dev, pmic); +platform_set_drvdata (pdev, pmic); pmic->dev = &pdev->dev; pmic->scu =devm_intel_scu_ipc_dev_get (&pdev->dev);
@@ -576,7 +576,7 @@ static int bxtwc_probe(struct platform_device *pdev)static void bxtwc_shutdown (struct platform_device *pdev) { -struct intel_soc_pmic *pmic =dev_get_drvdata (&pdev->dev); +struct intel_soc_pmic *pmic =platform_get_drvdata (pdev);disable_irq (pmic->irq); }
Signature · 1 line
2.35.1
Re: [PATCH v1 03/11] mfd: intel_soc_pmic_bxtwc: Convert to use platform_get/set_drvdata()
Quoted 8 lines · Andy Shevchenko
We have the specific helpers for platform device to set and get its driver data. Convert driver to use them instead of open coded variants.
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 4/11 mfd: intel_soc_pmic_bxtwc: Use dev_err_probe()
In reply to Andy ShevchenkoSimplify the mux error path a bit by using dev_err_probe().
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 86 +++++++++--------------------- 1 file changed, 26 insertions(+), 60 deletions(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +26 -60
@@ -419,12 +419,9 @@ static int bxtwc_add_chained_irq_chip(struct intel_soc_pmic *pmic,int irq; irq =regmap_irq_get_virq (pdata, pirq); -if (irq <0 ) { -dev_err (pmic->dev, -"Failed to get parent vIRQ(%d) for chip %s, ret:%d\n" , - pirq, chip->name, irq); -return irq; - } +if (irq <0 ) +return dev_err_probe (pmic->dev, irq,"Failed to get parent vIRQ(%d) for chip %s\n" , + pirq, chip->name);return devm_regmap_add_irq_chip (pmic->dev, pmic->regmap, irq, irq_flags,0 , chip, data);
@@ -432,6 +429,7 @@ static int bxtwc_add_chained_irq_chip(struct intel_soc_pmic *pmic,static int bxtwc_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev;int ret;acpi_handle handle;acpi_status status;
@@ -440,15 +438,10 @@ static int bxtwc_probe(struct platform_device *pdev) handle =ACPI_HANDLE (&pdev->dev); status =acpi_evaluate_integer (handle,"_HRV" ,NULL , &hrv); -if (ACPI_FAILURE (status)) { -dev_err (&pdev->dev,"Failed to get PMIC hardware revision\n" ); -return -ENODEV ; - } -if (hrv !=BROXTON_PMIC_WC_HRV ) { -dev_err (&pdev->dev,"Invalid PMIC hardware revision: %llu\n" , - hrv); -return -ENODEV ; - } +if (ACPI_FAILURE (status)) +return dev_err_probe (dev, -ENODEV ,"Failed to get PMIC hardware revision\n" ); +if (hrv !=BROXTON_PMIC_WC_HRV ) +return dev_err_probe (dev, -ENODEV ,"Invalid PMIC hardware revision: %llu\n" , hrv); pmic =devm_kzalloc (&pdev->dev,sizeof (*pmic),GFP_KERNEL );if (!pmic)
@@ -468,40 +461,31 @@ static int bxtwc_probe(struct platform_device *pdev) pmic->regmap =devm_regmap_init (&pdev->dev,NULL , pmic, &bxtwc_regmap_config); -if (IS_ERR (pmic->regmap)) { - ret =PTR_ERR (pmic->regmap); -dev_err (&pdev->dev,"Failed to initialise regmap: %d\n" , ret); -return ret; - } +if (IS_ERR (pmic->regmap)) +return dev_err_probe (dev,PTR_ERR (pmic->regmap),"Failed to initialise regmap\n" ); ret =devm_regmap_add_irq_chip (&pdev->dev, pmic->regmap, pmic->irq,IRQF_ONESHOT |IRQF_SHARED ,0 , &bxtwc_regmap_irq_chip, &pmic->irq_chip_data); -if (ret) { -dev_err (&pdev->dev,"Failed to add IRQ chip\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to add IRQ chip\n" ); ret =bxtwc_add_chained_irq_chip (pmic, pmic->irq_chip_data,BXTWC_PWRBTN_LVL1_IRQ ,IRQF_ONESHOT , &bxtwc_regmap_irq_chip_pwrbtn, &pmic->irq_chip_data_pwrbtn); -if (ret) { -dev_err (&pdev->dev,"Failed to add PWRBTN IRQ chip\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to add PWRBTN IRQ chip\n" ); ret =bxtwc_add_chained_irq_chip (pmic, pmic->irq_chip_data,BXTWC_TMU_LVL1_IRQ ,IRQF_ONESHOT , &bxtwc_regmap_irq_chip_tmu, &pmic->irq_chip_data_tmu); -if (ret) { -dev_err (&pdev->dev,"Failed to add TMU IRQ chip\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to add TMU IRQ chip\n" );/* Add chained IRQ handler for BCU IRQs */ ret = bxtwc_add_chained_irq_chip(pmic, pmic->irq_chip_data,
@@ -509,12 +493,8 @@ static int bxtwc_probe(struct platform_device *pdev)IRQF_ONESHOT , &bxtwc_regmap_irq_chip_bcu, &pmic->irq_chip_data_bcu); - - -if (ret) { -dev_err (&pdev->dev,"Failed to add BUC IRQ chip\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to add BUC IRQ chip\n" );/* Add chained IRQ handler for ADC IRQs */ ret = bxtwc_add_chained_irq_chip(pmic, pmic->irq_chip_data,
@@ -522,12 +502,8 @@ static int bxtwc_probe(struct platform_device *pdev)IRQF_ONESHOT , &bxtwc_regmap_irq_chip_adc, &pmic->irq_chip_data_adc); - - -if (ret) { -dev_err (&pdev->dev,"Failed to add ADC IRQ chip\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to add ADC IRQ chip\n" );/* Add chained IRQ handler for CHGR IRQs */ ret = bxtwc_add_chained_irq_chip(pmic, pmic->irq_chip_data,
@@ -535,12 +511,8 @@ static int bxtwc_probe(struct platform_device *pdev)IRQF_ONESHOT , &bxtwc_regmap_irq_chip_chgr, &pmic->irq_chip_data_chgr); - - -if (ret) { -dev_err (&pdev->dev,"Failed to add CHGR IRQ chip\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to add CHGR IRQ chip\n" );/* Add chained IRQ handler for CRIT IRQs */ ret = bxtwc_add_chained_irq_chip(pmic, pmic->irq_chip_data,
@@ -548,19 +520,13 @@ static int bxtwc_probe(struct platform_device *pdev)IRQF_ONESHOT , &bxtwc_regmap_irq_chip_crit, &pmic->irq_chip_data_crit); - - -if (ret) { -dev_err (&pdev->dev,"Failed to add CRIT IRQ chip\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to add CRIT IRQ chip\n" ); ret =devm_mfd_add_devices (&pdev->dev,PLATFORM_DEVID_NONE , bxt_wc_dev,ARRAY_SIZE (bxt_wc_dev),NULL ,0 ,NULL ); -if (ret) { -dev_err (&pdev->dev,"Failed to add devices\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"Failed to add devices\n" );/* * There is known hw bug. Upon reset BIT 5 of register
Signature · 1 line
2.35.1
Re: [PATCH v1 04/11] mfd: intel_soc_pmic_bxtwc: Use dev_err_probe()
Quoted 6 lines · Andy Shevchenko
Simplify the mux error path a bit by using
dev_err_probe().Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 86 +++++++++--------------------- 1 file changed, 26 insertions(+), 60 deletions(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 5/11 mfd: intel_soc_pmic_bxtwc: Extend use of temporary variable for struct device
In reply to Andy ShevchenkoExtend use of temporary variable for struct device to make code neater.
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +8 -11
@@ -431,19 +431,17 @@ static int bxtwc_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;int ret; -acpi_handle handle;acpi_status status;unsigned long long hrv;struct intel_soc_pmic *pmic; - handle =ACPI_HANDLE (&pdev->dev); - status =acpi_evaluate_integer (handle,"_HRV" ,NULL , &hrv); + status =acpi_evaluate_integer (ACPI_HANDLE (dev),"_HRV" ,NULL , &hrv);if (ACPI_FAILURE (status))return dev_err_probe (dev, -ENODEV ,"Failed to get PMIC hardware revision\n" );if (hrv !=BROXTON_PMIC_WC_HRV )return dev_err_probe (dev, -ENODEV ,"Invalid PMIC hardware revision: %llu\n" , hrv); - pmic =devm_kzalloc (&pdev->dev,sizeof (*pmic),GFP_KERNEL ); + pmic =devm_kzalloc (dev,sizeof (*pmic),GFP_KERNEL );if (!pmic)return -ENOMEM ;
@@ -453,18 +451,17 @@ static int bxtwc_probe(struct platform_device *pdev) pmic->irq = ret;platform_set_drvdata (pdev, pmic); - pmic->dev = &pdev->dev; + pmic->dev = dev; - pmic->scu =devm_intel_scu_ipc_dev_get (&pdev->dev); + pmic->scu =devm_intel_scu_ipc_dev_get (dev);if (!pmic->scu)return -EPROBE_DEFER ; - pmic->regmap =devm_regmap_init (&pdev->dev,NULL , pmic, - &bxtwc_regmap_config); + pmic->regmap =devm_regmap_init (dev,NULL , pmic, &bxtwc_regmap_config);if (IS_ERR (pmic->regmap))return dev_err_probe (dev,PTR_ERR (pmic->regmap),"Failed to initialise regmap\n" ); - ret =devm_regmap_add_irq_chip (&pdev->dev, pmic->regmap, pmic->irq, + ret =devm_regmap_add_irq_chip (dev, pmic->regmap, pmic->irq,IRQF_ONESHOT |IRQF_SHARED ,0 , &bxtwc_regmap_irq_chip, &pmic->irq_chip_data);
@@ -523,8 +520,8 @@ static int bxtwc_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"Failed to add CRIT IRQ chip\n" ); - ret =devm_mfd_add_devices (&pdev->dev,PLATFORM_DEVID_NONE , bxt_wc_dev, -ARRAY_SIZE (bxt_wc_dev),NULL ,0 ,NULL ); + ret =devm_mfd_add_devices (dev,PLATFORM_DEVID_NONE , bxt_wc_dev,ARRAY_SIZE (bxt_wc_dev), +NULL ,0 ,NULL );if (ret)return dev_err_probe (dev, ret,"Failed to add devices\n" );
Signature · 1 line
2.35.1
Re: [PATCH v1 05/11] mfd: intel_soc_pmic_bxtwc: Extend use of temporary variable for struct device
Quoted 6 lines · Andy Shevchenko
Extend use of temporary variable for struct device to make code neater.
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 6/11 mfd: intel_soc_pmic_bxtwc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
In reply to Andy ShevchenkoLetting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +3 -4
@@ -544,7 +544,6 @@ static void bxtwc_shutdown(struct platform_device *pdev)disable_irq (pmic->irq); } -#ifdef CONFIG_PM_SLEEP static int bxtwc_suspend (struct device *dev) {struct intel_soc_pmic *pmic =dev_get_drvdata (dev);
@@ -561,8 +560,8 @@ static int bxtwc_resume(struct device *dev)enable_irq (pmic->irq);return 0 ; } -#endif -static SIMPLE_DEV_PM_OPS(bxtwc_pm_ops, bxtwc_suspend, bxtwc_resume); + +static DEFINE_SIMPLE_DEV_PM_OPS(bxtwc_pm_ops, bxtwc_suspend, bxtwc_resume);static const struct acpi_device_id bxtwc_acpi_ids[] = { {"INT34D3" , },
@@ -575,7 +574,7 @@ static struct platform_driver bxtwc_driver = { .shutdown = bxtwc_shutdown, .driver = { .name = "BXTWC PMIC", - .pm = &bxtwc_pm_ops, + .pm = pm_sleep_ptr(&bxtwc_pm_ops), .acpi_match_table = ACPI_PTR(bxtwc_acpi_ids), .dev_groups = bxtwc_groups, },
Signature · 1 line
2.35.1
Re: [PATCH v1 06/11] mfd: intel_soc_pmic_bxtwc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
Quoted 8 lines · Andy Shevchenko
Letting the compiler remove these functions when the kernel is built without
CONFIG_PM_SLEEPsupport is simpler and less error prone than the use of #ifdef based kernel configuration guards.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 7/11 mfd: intel_soc_pmic_bxtwc: Drop redundant ACPI_PTR()
In reply to Andy ShevchenkoThe driver depends on ACPI (via MFD_INTEL_PMC_BXT), ACPI_PTR() resolution is always the same. Otherwise a compiler may produce a warning.
That said, the rule of thumb either ugly ifdeffery with ACPI_PTR or none should be used in a driver.
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +1 -1
@@ -575,7 +575,7 @@ static struct platform_driver bxtwc_driver = { .driver = { .name = "BXTWC PMIC", .pm = pm_sleep_ptr(&bxtwc_pm_ops), - .acpi_match_table = ACPI_PTR(bxtwc_acpi_ids), + .acpi_match_table = bxtwc_acpi_ids, .dev_groups = bxtwc_groups, }, };
Signature · 1 line
2.35.1
Re: [PATCH v1 07/11] mfd: intel_soc_pmic_bxtwc: Drop redundant ACPI_PTR()
Quoted 10 lines · Andy Shevchenko
The driver depends on ACPI (via
MFD_INTEL_PMC_BXT),ACPI_PTR()resolution is always the same. Otherwise a compiler may produce a warning.That said, the rule of thumb either ugly ifdeffery with
ACPI_PTRor none should be used in a driver.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 8/11 mfd: intel_soc_pmic_bxtwc: Use bits.h macros for all masks
In reply to Andy ShevchenkoCurrently we are using BIT(), but GENMASK(). Make use of the latter one as well (far less error-prone, far more concise).
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +11 -10
@@ -6,6 +6,7 @@*/ #include <linux/acpi.h> +#include <linux/bits.h> #include <linux/delay.h> #include <linux/err.h> #include <linux/interrupt.h>
@@ -18,9 +19,9 @@#include <asm/intel_scu_ipc.h> /* PMIC device registers */ -#define REG_ADDR_MASK 0xFF00 +#define REG_ADDR_MASK GENMASK(15, 8)#define REG_ADDR_SHIFT 8 -#define REG_OFFSET_MASK 0xFF +#define REG_OFFSET_MASK GENMASK(7, 0)/* Interrupt Status Registers */ #define BXTWC_IRQLVL1 0x4E02
@@ -112,29 +113,29 @@ static const struct regmap_irq bxtwc_regmap_irqs[] = { };static const struct regmap_irq bxtwc_regmap_irqs_pwrbtn[] = { -REGMAP_IRQ_REG (BXTWC_PWRBTN_IRQ ,0 ,0x01 ), +REGMAP_IRQ_REG (BXTWC_PWRBTN_IRQ ,0 ,BIT (0 )), };static const struct regmap_irq bxtwc_regmap_irqs_bcu[] = { -REGMAP_IRQ_REG (BXTWC_BCU_IRQ ,0 ,0x1f ), +REGMAP_IRQ_REG (BXTWC_BCU_IRQ ,0 ,GENMASK (4 ,0 )), };static const struct regmap_irq bxtwc_regmap_irqs_adc[] = { -REGMAP_IRQ_REG (BXTWC_ADC_IRQ ,0 ,0xff ), +REGMAP_IRQ_REG (BXTWC_ADC_IRQ ,0 ,GENMASK (7 ,0 )), };static const struct regmap_irq bxtwc_regmap_irqs_chgr[] = { -REGMAP_IRQ_REG (BXTWC_USBC_IRQ ,0 ,0x20 ), -REGMAP_IRQ_REG (BXTWC_CHGR0_IRQ ,0 ,0x1f ), -REGMAP_IRQ_REG (BXTWC_CHGR1_IRQ ,1 ,0x1f ), +REGMAP_IRQ_REG (BXTWC_USBC_IRQ ,0 ,BIT (5 )), +REGMAP_IRQ_REG (BXTWC_CHGR0_IRQ ,0 ,GENMASK (4 ,0 )), +REGMAP_IRQ_REG (BXTWC_CHGR1_IRQ ,1 ,GENMASK (4 ,0 )), };static const struct regmap_irq bxtwc_regmap_irqs_tmu[] = { -REGMAP_IRQ_REG (BXTWC_TMU_IRQ ,0 ,0x06 ), +REGMAP_IRQ_REG (BXTWC_TMU_IRQ ,0 ,GENMASK (2 ,1 )), };static const struct regmap_irq bxtwc_regmap_irqs_crit[] = { -REGMAP_IRQ_REG (BXTWC_CRIT_IRQ ,0 ,0x03 ), +REGMAP_IRQ_REG (BXTWC_CRIT_IRQ ,0 ,GENMASK (1 ,0 )), };static struct regmap_irq_chip bxtwc_regmap_irq_chip = {
Signature · 1 line
2.35.1
Re: [PATCH v1 08/11] mfd: intel_soc_pmic_bxtwc: Use bits.h macros for all masks
On Thu, 16 Jun 2022, Andy Shevchenko wrote:
65;6800;1c
Quoted 7 lines
Currently we are using
BIT(), butGENMASK(). Make use of the latter one as well (far less error-prone, far more concise).Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 9/11 mfd: intel_soc_pmic_bxtwc: Use sysfs_emit() instead of sprintf()
In reply to Andy Shevchenkosysfs_emit() is preferred over sprintf() when formatting the value to be returned to user space in show() functions, because it knows about sysfs buffer specifics and has sanity checks.
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +2 -2
@@ -334,7 +334,7 @@ static unsigned long bxtwc_reg_addr;static ssize_t addr_show (struct device *dev,struct device_attribute *attr,char *buf) { -return sprintf (buf,"0x%lx\n" , bxtwc_reg_addr); +return sysfs_emit (buf,"0x%lx\n" , bxtwc_reg_addr); } static ssize_t addr_store(struct device *dev,
@@ -364,7 +364,7 @@ static ssize_t val_show(struct device *dev,return ret; } -return sprintf (buf,"0x%02x\n" , val); +return sysfs_emit (buf,"0x%02x\n" , val); } static ssize_t val_store(struct device *dev,
Signature · 1 line
2.35.1
Re: [PATCH v1 09/11] mfd: intel_soc_pmic_bxtwc: Use sysfs_emit() instead of sprintf()
Quoted 8 lines · Andy Shevchenko
sysfs_emit()is preferred oversprintf()when formatting the value to be returned to user space inshow()functions, because it knows about sysfs buffer specifics and has sanity checks.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 10/11 mfd: intel_soc_pmic_bxtwc: Drop unneeded casting
In reply to Andy ShevchenkoThe casting from size_t to ssize_t is not needed in addr_store(), drop it.
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +1 -1
@@ -348,7 +348,7 @@ static ssize_t addr_store(struct device *dev,return ret; } -return (ssize_t )count; +return count; } static ssize_t val_show(struct device *dev,
Signature · 1 line
2.35.1
Re: [PATCH v1 10/11] mfd: intel_soc_pmic_bxtwc: Drop unneeded casting
Quoted 7 lines · Andy Shevchenko
The casting from
size_ttossize_tis not needed inaddr_store(), drop it.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
For my own reference (apply this as-is to your sign-off block):
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 11/11 mfd: intel_soc_pmic_bxtwc: Fix spelling in the comment
In reply to Andy ShevchenkoThere are a couple of spelling issues in the comment, fix them. While at it, fix indentation in the MODULE_AUTHOR() parameter and update copyright years.
--- drivers/mfd/intel_soc_pmic_bxtwc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mfd/intel_soc_pmic_bxtwc.c +5 -5
@@ -2,7 +2,7 @@/* * MFD core driver for Intel Broxton Whiskey Cove PMIC * -* Copyright (C) 2015 Intel Corporation. All rights reserved. +* Copyright (C) 2015-2017, 2022 Intel Corporation. All rights reserved. */ #include <linux/acpi.h>
@@ -527,11 +527,11 @@ static int bxtwc_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"Failed to add devices\n" );/* -* There is known hw bug. Upon reset BIT 5 of register +* There is known HW bug. Upon reset BIT 5 of register * BXTWC_CHGR_LVL1_IRQ is 0 which is the expected value. However, * later it's set to 1(masked) automatically by hardware. So we -* have the software workaround here to unmaksed it in order to let -* charger interrutp work. +* have the software workaround here to unmasked it in order to let +* charger interrupt work. */ regmap_update_bits (pmic->regmap,BXTWC_MIRQLVL1 ,BXTWC_MIRQLVL1_MCHGR ,0 );
@@ -584,4 +584,4 @@ static struct platform_driver bxtwc_driver = {module_platform_driver (bxtwc_driver);MODULE_LICENSE ("GPL v2" ); -MODULE_AUTHOR ("Qipeng Zha<[email protected]>" ); +MODULE_AUTHOR ("Qipeng Zha <[email protected]>" );
Signature · 1 line
2.35.1
Re: [PATCH v1 11/11] mfd: intel_soc_pmic_bxtwc: Fix spelling in the comment
Quoted 14 lines · Andy Shevchenko
There are a couple of spelling issues in the comment, fix them. While at it, fix indentation in the
MODULE_AUTHOR()parameter and update copyright years.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/mfd/intel_soc_pmic_bxtwc.c +0
-0
drivers/mfd/intel_soc_pmic_bxtwc.c line 5
Quoted 5 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +1
-1@@ -2,7 +2,7 @@/* * MFD core driver for Intel Broxton Whiskey Cove PMIC * -* Copyright (C) 2015 Intel Corporation. All rights reserved. +* Copyright (C) 2015-2017, 2022 Intel Corporation. All rights reserved.
I do not profess to be an expert. What happened between 2017-2022?
drivers/mfd/intel_soc_pmic_bxtwc.c static int bxtwc_probe(struct platform_device *pdev) · line 530
Quoted 9 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +1
-1*/ #include <linux/acpi.h> @@ -527,11 +527,11 @@ static int bxtwc_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"Failed to add devices\n" );/* -* There is known hw bug. Upon reset BIT 5 of register +* There is known HW bug. Upon reset BIT 5 of register
You may as well fix the grammar while you're at it.
drivers/mfd/intel_soc_pmic_bxtwc.c static int bxtwc_probe(struct platform_device *pdev) · line 534
Quoted 6 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +2
-2* BXTWC_CHGR_LVL1_IRQ is 0 which is the expected value. However, * later it's set to 1(masked) automatically by hardware. So we -* have the software workaround here to unmaksed it in order to let -* charger interrutp work. +* have the software workaround here to unmasked it in order to let +* charger interrupt work.
Likewise.
Quoted 9 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +1
-1*/ regmap_update_bits (pmic->regmap,BXTWC_MIRQLVL1 ,BXTWC_MIRQLVL1_MCHGR ,0 );@@ -584,4 +584,4 @@ static struct platform_driver bxtwc_driver = {module_platform_driver (bxtwc_driver);MODULE_LICENSE ("GPL v2" ); -MODULE_AUTHOR ("Qipeng Zha<[email protected]>" ); +MODULE_AUTHOR ("Qipeng Zha <[email protected]>" );
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v1 11/11] mfd: intel_soc_pmic_bxtwc: Fix spelling in the comment
Quoted 1 line · Lee Jones
On Thu, 16 Jun 2022, Andy Shevchenko wrote:
...
Quoted 4 lines
Quoted 2 lines
- * Copyright (C) 2015 Intel Corporation. All rights reserved.
+ * Copyright (C) 2015-2017, 2022 Intel Corporation. All rights reserved.I do not profess to be an expert. What happened between 2017-2022?
Nothing?
I mean that before I become a reviewer/maintainer of this code I have no evidence that anyone at Intel worked on the code (I mean really working, not some whitespace cleanup). After that I don't remember I was doing anything (important) either.
...
Quoted 4 lines
drivers/mfd/intel_soc_pmic_bxtwc.c static int bxtwc_probe(struct platform_device *pdev) · line 530
Quoted 2 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +1
-1-* There is known hw bug. Upon reset BIT 5 of register +* There is known HW bug. Upon reset BIT 5 of register You may as well fix the grammar while you're at it.
Any suggestion from a native speaker? I can propose a few changes, but I'm totally unsure.
Quoted 8 lines
drivers/mfd/intel_soc_pmic_bxtwc.c static int bxtwc_probe(struct platform_device *pdev) · line 534
Quoted 6 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +2
-2* BXTWC_CHGR_LVL1_IRQ is 0 which is the expected value. However, * later it's set to 1(masked) automatically by hardware. So we -* have the software workaround here to unmaksed it in order to let -* charger interrutp work. +* have the software workaround here to unmasked it in order to let +* charger interrupt work. Likewise.
Likewise.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 11/11] mfd: intel_soc_pmic_bxtwc: Fix spelling in the comment
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Lee Jones
drivers/mfd/intel_soc_pmic_bxtwc.c static int bxtwc_probe(struct platform_device *pdev) · line 530
Quoted 2 lines · Andy Shevchenko
drivers/mfd/intel_soc_pmic_bxtwc.c +1
-1-* There is known hw bug. Upon reset BIT 5 of register +* There is known HW bug. Upon reset BIT 5 of register You may as well fix the grammar while you're at it.
Any suggestion from a native speaker? I can propose a few changes, but I'm totally unsure.
No massive changes, just:
* There is a known H/W bug. Upon reset, BIT 5 of register
- --- -
Quoted 6 lines
Quoted 6 lines
drivers/mfd/intel_soc_pmic_bxtwc.c static int bxtwc_probe(struct platform_device *pdev) · line 534
Quoted 6 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +2
-2* BXTWC_CHGR_LVL1_IRQ is 0 which is the expected value. However, * later it's set to 1(masked) automatically by hardware. So we -* have the software workaround here to unmaksed it in order to let -* charger interrutp work. +* have the software workaround here to unmasked it in order to let +* charger interrupt work.
* place a software workaround here to unmask it again in order to re-enable
------- ------ ----- ---------
* the charger interrupt.
---
Something like that. Feel free to adapt it further as you see fit.
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v1 11/11] mfd: intel_soc_pmic_bxtwc: Fix spelling in the comment
Quoted 27 lines · Lee Jones
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Lee Jones
drivers/mfd/intel_soc_pmic_bxtwc.c static int bxtwc_probe(struct platform_device *pdev) · line 530
Quoted 2 lines · Andy Shevchenko
drivers/mfd/intel_soc_pmic_bxtwc.c +1
-1-* There is known hw bug. Upon reset BIT 5 of register +* There is known HW bug. Upon reset BIT 5 of register You may as well fix the grammar while you're at it.
Any suggestion from a native speaker? I can propose a few changes, but I'm totally unsure.
No massive changes, just:
* There is a known H/W bug. Upon reset, BIT 5 of register
- --- -Quoted 6 lines
Quoted 6 lines
drivers/mfd/intel_soc_pmic_bxtwc.c static int bxtwc_probe(struct platform_device *pdev) · line 534
Quoted 6 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +2
-2* BXTWC_CHGR_LVL1_IRQ is 0 which is the expected value. However, * later it's set to 1(masked) automatically by hardware. So we -* have the software workaround here to unmaksed it in order to let -* charger interrutp work. +* have the software workaround here to unmasked it in order to let +* charger interrupt work. * place a software workaround here to unmask it again in order to re-enable
------- ------ ----- ---------
Quoted 4 lines
* the charger interrupt.
---Something like that. Feel free to adapt it further as you see fit.
Thank you, Lee, I will do as suggested!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
kstrtox()along with regmap API can return different error codes based on circumstances.Don't shadow them when returning to the caller.
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/mfd/intel_soc_pmic_bxtwc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)drivers/mfd/intel_soc_pmic_bxtwc.c +0
-0
drivers/mfd/intel_soc_pmic_bxtwc.c static ssize_t addr_show(struct device *dev, · line 346
Quoted 9 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +4
-1@@ -339,10 +339,14 @@ static ssize_t addr_show(struct device *dev,static ssize_t addr_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -if (kstrtoul (buf,0 , &bxtwc_reg_addr)) { +int ret; + + ret =kstrtoul (buf,0 , &bxtwc_reg_addr); +if (ret) {dev_err (dev,"Invalid register address\n" );
Is that really what failure means, on every failure?
"Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing
error."
Quoted 28 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +5
-4-return -EINVAL ; +return ret; } +return (ssize_t )count; }@@ -354,9 +358,9 @@ static ssize_t val_show(struct device *dev,struct intel_soc_pmic *pmic =dev_get_drvdata (dev); ret =regmap_read (pmic->regmap, bxtwc_reg_addr, &val); -if (ret <0 ) { +if (ret) {dev_err (dev,"Failed to read 0x%lx\n" , bxtwc_reg_addr); -return -EIO ; +return ret; }return sprintf (buf,"0x%02x\n" , val);@@ -377,7 +381,7 @@ static ssize_t val_store(struct device *dev,if (ret) {dev_err (dev,"Failed to write value 0x%02x to address 0x%lx" , val, bxtwc_reg_addr); -return -EIO ; +return ret; }return count; }
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 1 line · Lee Jones
On Thu, 16 Jun 2022, Andy Shevchenko wrote:
...
Quoted 8 lines
drivers/mfd/intel_soc_pmic_bxtwc.c static ssize_t addr_show(struct device *dev, · line 346
Quoted 3 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +2
-0+ ret =kstrtoul (buf,0 , &bxtwc_reg_addr); +if (ret) {dev_err (dev,"Invalid register address\n" );Is that really what failure means, on every failure?
"Returns 0 on success,
-ERANGEon overflow and-EINVALon parsing
error."
As far as I can see in either case the address is invalid. Basically we may drop this confusing error message here, if this what you prefer.
Quoted 3 lines
Quoted 3 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +1
-1-return -EINVAL ; +return ret; }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 11 lines · Andy Shevchenko
Quoted 1 line · Lee Jones
On Thu, 16 Jun 2022, Andy Shevchenko wrote:
...
Quoted 6 lines
drivers/mfd/intel_soc_pmic_bxtwc.c static ssize_t addr_show(struct device *dev, · line 346
Quoted 3 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +2
-0+ ret =kstrtoul (buf,0 , &bxtwc_reg_addr); +if (ret) {dev_err (dev,"Invalid register address\n" );Is that really what failure means, on every failure?
Quoted 6 lines
Quoted 2 lines
"Returns 0 on success,
-ERANGEon overflow and-EINVALon parsing
error."As far as I can see in either case the address is invalid. Basically we may drop this confusing error message here, if this what you prefer.
Your call. I just wanted you to consider it for a moment.
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 3 lines · Lee Jones
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Lee Jones
On Thu, 16 Jun 2022, Andy Shevchenko wrote:
...
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/mfd/intel_soc_pmic_bxtwc.c static ssize_t addr_show(struct device *dev, · line 346
Quoted 3 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +2
-0+ ret =kstrtoul (buf,0 , &bxtwc_reg_addr); +if (ret) {dev_err (dev,"Invalid register address\n" );Is that really what failure means, on every failure?
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
"Returns 0 on success,
-ERANGEon overflow and-EINVALon parsing
error."As far as I can see in either case the address is invalid. Basically we may drop this confusing error message here, if this what you prefer.
Your call. I just wanted you to consider it for a moment.
Userspace will print an error based on the error code, so I would rather remove _this_ message since it doesn't add value, esp. when we could have -ERANGE.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 20 lines · Andy Shevchenko
Quoted 3 lines · Lee Jones
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Lee Jones
On Thu, 16 Jun 2022, Andy Shevchenko wrote:
...
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
drivers/mfd/intel_soc_pmic_bxtwc.c static ssize_t addr_show(struct device *dev, · line 346
Quoted 3 lines
drivers/mfd/intel_soc_pmic_bxtwc.c +2
-0+ ret =kstrtoul (buf,0 , &bxtwc_reg_addr); +if (ret) {dev_err (dev,"Invalid register address\n" );Is that really what failure means, on every failure?
"Returns 0 on success,
-ERANGEon overflow and-EINVALon parsing
error."As far as I can see in either case the address is invalid. Basically we may drop this confusing error message here, if this what you prefer.
Quoted 5 lines
Quoted 1 line
Your call. I just wanted you to consider it for a moment.
Userspace will print an error based on the error code, so I would rather remove _this_ message since it doesn't add value, esp. when we could have
-ERANGE.
Works for me.
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog