mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups
@ 2024-10-16 10:49 Andy Shevchenko
  2024-10-16 10:49 ` [PATCH v1 1/4] mfd: intel_soc_pmic_bxtwc: Switch to use ATTRIBUTE_GROUPS() Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-16 10:49 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel; +Cc: Andy Shevchenko, Lee Jones

While working on the fixes series against the driver I have noticed some
places that can be improved using better APIs or approaches. Hence this
mini-series. The plus statistics is due to the patch 2 that brought
missed inclusions to the code (instead of using a proxy header).

Have been tested on Intel Joule device.

Andy Shevchenko (4):
  mfd: intel_soc_pmic_bxtwc: Switch to use ATTRIBUTE_GROUPS()
  mfd: intel_soc_pmic_bxtwc: Don't use "proxy" headers
  mfd: intel_soc_pmic_bxtwc: Use temporary variable for struct device
  mfd: intel_soc_pmic_bxtwc: Deduplicate error messages

 drivers/mfd/intel_soc_pmic_bxtwc.c | 45 +++++++++++++++++-------------
 1 file changed, 26 insertions(+), 19 deletions(-)

-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 1/4] mfd: intel_soc_pmic_bxtwc: Switch to use ATTRIBUTE_GROUPS()
  2024-10-16 10:49 [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups Andy Shevchenko
@ 2024-10-16 10:49 ` Andy Shevchenko
  2024-10-16 10:49 ` [PATCH v1 2/4] mfd: intel_soc_pmic_bxtwc: Don't use "proxy" headers Andy Shevchenko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-16 10:49 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel; +Cc: Andy Shevchenko, Lee Jones

Embrace ATTRIBUTE_GROUPS() to avoid boiler plate code.
While at it, move DEVICE_ATTR_ADMIN_RW() closer to the callbacks.

This should not introduce any functional changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mfd/intel_soc_pmic_bxtwc.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
index b7204072e93e..c130734f308e 100644
--- a/drivers/mfd/intel_soc_pmic_bxtwc.c
+++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
@@ -364,6 +364,7 @@ static ssize_t addr_store(struct device *dev,
 
 	return count;
 }
+static DEVICE_ATTR_ADMIN_RW(addr);
 
 static ssize_t val_show(struct device *dev,
 			struct device_attribute *attr, char *buf)
@@ -400,23 +401,14 @@ static ssize_t val_store(struct device *dev,
 	}
 	return count;
 }
-
-static DEVICE_ATTR_ADMIN_RW(addr);
 static DEVICE_ATTR_ADMIN_RW(val);
+
 static struct attribute *bxtwc_attrs[] = {
 	&dev_attr_addr.attr,
 	&dev_attr_val.attr,
 	NULL
 };
-
-static const struct attribute_group bxtwc_group = {
-	.attrs = bxtwc_attrs,
-};
-
-static const struct attribute_group *bxtwc_groups[] = {
-	&bxtwc_group,
-	NULL
-};
+ATTRIBUTE_GROUPS(bxtwc);
 
 static const struct regmap_config bxtwc_regmap_config = {
 	.reg_bits = 16,
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 2/4] mfd: intel_soc_pmic_bxtwc: Don't use "proxy" headers
  2024-10-16 10:49 [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups Andy Shevchenko
  2024-10-16 10:49 ` [PATCH v1 1/4] mfd: intel_soc_pmic_bxtwc: Switch to use ATTRIBUTE_GROUPS() Andy Shevchenko
@ 2024-10-16 10:49 ` Andy Shevchenko
  2024-10-16 10:49 ` [PATCH v1 3/4] mfd: intel_soc_pmic_bxtwc: Use temporary variable for struct device Andy Shevchenko
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-16 10:49 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel; +Cc: Andy Shevchenko, Lee Jones

Update header inclusions to follow IWYU (Include What You Use)
principle.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mfd/intel_soc_pmic_bxtwc.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
index c130734f308e..1469e89b88ce 100644
--- a/drivers/mfd/intel_soc_pmic_bxtwc.c
+++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
@@ -6,16 +6,27 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/array_size.h>
 #include <linux/bits.h>
 #include <linux/delay.h>
+#include <linux/device.h>
 #include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/gfp_types.h>
 #include <linux/interrupt.h>
-#include <linux/kernel.h>
+#include <linux/ioport.h>
+#include <linux/kstrtox.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/intel_soc_pmic.h>
 #include <linux/mfd/intel_soc_pmic_bxtwc.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/x86/intel_scu_ipc.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/regmap.h>
+#include <linux/sysfs.h>
+#include <linux/types.h>
 
 /* PMIC device registers */
 #define REG_ADDR_MASK		GENMASK(15, 8)
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 3/4] mfd: intel_soc_pmic_bxtwc: Use temporary variable for struct device
  2024-10-16 10:49 [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups Andy Shevchenko
  2024-10-16 10:49 ` [PATCH v1 1/4] mfd: intel_soc_pmic_bxtwc: Switch to use ATTRIBUTE_GROUPS() Andy Shevchenko
  2024-10-16 10:49 ` [PATCH v1 2/4] mfd: intel_soc_pmic_bxtwc: Don't use "proxy" headers Andy Shevchenko
@ 2024-10-16 10:49 ` Andy Shevchenko
  2024-10-16 10:49 ` [PATCH v1 4/4] mfd: intel_soc_pmic_bxtwc: Deduplicate error messages Andy Shevchenko
  2024-10-31 14:59 ` [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups Lee Jones
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-16 10:49 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel; +Cc: Andy Shevchenko, Lee Jones

Use a temporary variable for the struct device pointers to avoid
dereferencing. This makes code a bit neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mfd/intel_soc_pmic_bxtwc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
index 1469e89b88ce..5e6cffb162a0 100644
--- a/drivers/mfd/intel_soc_pmic_bxtwc.c
+++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
@@ -434,15 +434,15 @@ static int bxtwc_add_chained_irq_chip(struct intel_soc_pmic *pmic,
 				const struct regmap_irq_chip *chip,
 				struct regmap_irq_chip_data **data)
 {
+	struct device *dev = pmic->dev;
 	int irq;
 
 	irq = regmap_irq_get_virq(pdata, pirq);
 	if (irq < 0)
-		return dev_err_probe(pmic->dev, irq, "Failed to get parent vIRQ(%d) for chip %s\n",
+		return dev_err_probe(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);
+	return devm_regmap_add_irq_chip(dev, pmic->regmap, irq, irq_flags, 0, chip, data);
 }
 
 static int bxtwc_add_chained_devices(struct intel_soc_pmic *pmic,
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 4/4] mfd: intel_soc_pmic_bxtwc: Deduplicate error messages
  2024-10-16 10:49 [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups Andy Shevchenko
                   ` (2 preceding siblings ...)
  2024-10-16 10:49 ` [PATCH v1 3/4] mfd: intel_soc_pmic_bxtwc: Use temporary variable for struct device Andy Shevchenko
@ 2024-10-16 10:49 ` Andy Shevchenko
  2024-10-31 14:59 ` [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups Lee Jones
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-16 10:49 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel; +Cc: Andy Shevchenko, Lee Jones

Move the individual error messages inside bxtwc_add_chained_irq_chip()
in order to deduplicate them.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mfd/intel_soc_pmic_bxtwc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
index 5e6cffb162a0..cc4056a64dbd 100644
--- a/drivers/mfd/intel_soc_pmic_bxtwc.c
+++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
@@ -435,14 +435,18 @@ static int bxtwc_add_chained_irq_chip(struct intel_soc_pmic *pmic,
 				struct regmap_irq_chip_data **data)
 {
 	struct device *dev = pmic->dev;
-	int irq;
+	int irq, ret;
 
 	irq = regmap_irq_get_virq(pdata, pirq);
 	if (irq < 0)
 		return dev_err_probe(dev, irq, "Failed to get parent vIRQ(%d) for chip %s\n",
 				     pirq, chip->name);
 
-	return devm_regmap_add_irq_chip(dev, pmic->regmap, irq, irq_flags, 0, chip, data);
+	ret = devm_regmap_add_irq_chip(dev, pmic->regmap, irq, irq_flags, 0, chip, data);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add %s IRQ chip\n", chip->name);
+
+	return 0;
 }
 
 static int bxtwc_add_chained_devices(struct intel_soc_pmic *pmic,
@@ -458,7 +462,7 @@ static int bxtwc_add_chained_devices(struct intel_soc_pmic *pmic,
 
 	ret = bxtwc_add_chained_irq_chip(pmic, pdata, pirq, irq_flags, chip, data);
 	if (ret)
-		return dev_err_probe(dev, ret, "Failed to add %s IRQ chip\n", chip->name);
+		return ret;
 
 	domain = regmap_irq_get_domain(*data);
 
@@ -521,7 +525,7 @@ static int bxtwc_probe(struct platform_device *pdev)
 					 &bxtwc_regmap_irq_chip_pwrbtn,
 					 &pmic->irq_chip_data_pwrbtn);
 	if (ret)
-		return dev_err_probe(dev, ret, "Failed to add PWRBTN IRQ chip\n");
+		return ret;
 
 	ret = bxtwc_add_chained_devices(pmic, bxt_wc_bcu_dev, ARRAY_SIZE(bxt_wc_bcu_dev),
 					pmic->irq_chip_data,
@@ -557,7 +561,7 @@ static int bxtwc_probe(struct platform_device *pdev)
 					 &bxtwc_regmap_irq_chip_crit,
 					 &pmic->irq_chip_data_crit);
 	if (ret)
-		return dev_err_probe(dev, ret, "Failed to add CRIT IRQ chip\n");
+		return ret;
 
 	ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, bxt_wc_dev, ARRAY_SIZE(bxt_wc_dev),
 				   NULL, 0, NULL);
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups
  2024-10-16 10:49 [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups Andy Shevchenko
                   ` (3 preceding siblings ...)
  2024-10-16 10:49 ` [PATCH v1 4/4] mfd: intel_soc_pmic_bxtwc: Deduplicate error messages Andy Shevchenko
@ 2024-10-31 14:59 ` Lee Jones
  4 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2024-10-31 14:59 UTC (permalink / raw)
  To: linux-kernel, Andy Shevchenko; +Cc: Andy Shevchenko, Lee Jones

On Wed, 16 Oct 2024 13:49:50 +0300, Andy Shevchenko wrote:
> While working on the fixes series against the driver I have noticed some
> places that can be improved using better APIs or approaches. Hence this
> mini-series. The plus statistics is due to the patch 2 that brought
> missed inclusions to the code (instead of using a proxy header).
> 
> Have been tested on Intel Joule device.
> 
> [...]

Applied, thanks!

[1/4] mfd: intel_soc_pmic_bxtwc: Switch to use ATTRIBUTE_GROUPS()
      commit: 1f9e418aafc6ee52aad25b85f1e799f031f8de67
[2/4] mfd: intel_soc_pmic_bxtwc: Don't use "proxy" headers
      commit: d2e77347ce9a4d70165f4e97d6a4133e48e678cc
[3/4] mfd: intel_soc_pmic_bxtwc: Use temporary variable for struct device
      commit: 3d6b7374f0d8b5f8945185e901a6f5e7ae887a16
[4/4] mfd: intel_soc_pmic_bxtwc: Deduplicate error messages
      commit: 4a8b3d48dad2ddbbb150602606c65bef3c2b3f8e

--
Lee Jones [李琼斯]


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-10-31 14:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-16 10:49 [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups Andy Shevchenko
2024-10-16 10:49 ` [PATCH v1 1/4] mfd: intel_soc_pmic_bxtwc: Switch to use ATTRIBUTE_GROUPS() Andy Shevchenko
2024-10-16 10:49 ` [PATCH v1 2/4] mfd: intel_soc_pmic_bxtwc: Don't use "proxy" headers Andy Shevchenko
2024-10-16 10:49 ` [PATCH v1 3/4] mfd: intel_soc_pmic_bxtwc: Use temporary variable for struct device Andy Shevchenko
2024-10-16 10:49 ` [PATCH v1 4/4] mfd: intel_soc_pmic_bxtwc: Deduplicate error messages Andy Shevchenko
2024-10-31 14:59 ` [PATCH v1 0/4] mfd: intel_soc_pmic_bxtwc: A few cleanups Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®