All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] spi: fsl-espi: remove unused variable in fsl_espi_setup
       [not found] ` <1d67ce99-42ea-c816-da35-e64575cca8ff-S0/GAf8tV78@public.gmane.org>
@ 2016-09-17 13:42   ` Heiner Kallweit
       [not found]     ` <a71abf9f-4254-af63-f7eb-1579faaeada3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2016-09-17 13:43   ` [PATCH 2/4] spi: fsl-espi: simplify of_fsl_espi_probe Heiner Kallweit
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Heiner Kallweit @ 2016-09-17 13:42 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

Remove an unused variable.

Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/spi-fsl-espi.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index a7984ae..4f9d9ec 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -361,7 +361,6 @@ out:
 static int fsl_espi_setup(struct spi_device *spi)
 {
 	struct mpc8xxx_spi *mpc8xxx_spi;
-	u32 hw_mode;
 	u32 loop_mode;
 	struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
 
@@ -379,7 +378,6 @@ static int fsl_espi_setup(struct spi_device *spi)
 
 	pm_runtime_get_sync(mpc8xxx_spi->dev);
 
-	hw_mode = cs->hw_mode; /* Save original settings */
 	cs->hw_mode = fsl_espi_read_reg(mpc8xxx_spi,
 					   ESPI_SPMODEx(spi->chip_select));
 	/* mask out bits we are going to set */
-- 
2.9.2


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 2/4] spi: fsl-espi: simplify of_fsl_espi_probe
       [not found] ` <1d67ce99-42ea-c816-da35-e64575cca8ff-S0/GAf8tV78@public.gmane.org>
  2016-09-17 13:42   ` [PATCH 1/4] spi: fsl-espi: remove unused variable in fsl_espi_setup Heiner Kallweit
@ 2016-09-17 13:43   ` Heiner Kallweit
       [not found]     ` <5bfd3921-5bb6-b9c3-dc64-3882491bba13-S0/GAf8tV78@public.gmane.org>
  2016-09-17 13:43   ` [PATCH 3/4] spi: fsl-espi: improve return value handling in fsl_espi_probe Heiner Kallweit
  2016-09-17 13:44   ` [PATCH 4/4] spi: fsl-espi: replace of_get_property with of_property_read_u32 Heiner Kallweit
  3 siblings, 1 reply; 11+ messages in thread
From: Heiner Kallweit @ 2016-09-17 13:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

Simplify of_fsl_espi_probe.

Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/spi-fsl-espi.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 4f9d9ec..dee3f82 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -685,7 +685,7 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
 	struct spi_master *master;
 	struct resource mem;
 	unsigned int irq;
-	int ret = -ENOMEM;
+	int ret;
 
 	ret = of_mpc8xxx_spi_probe(ofdev);
 	if (ret)
@@ -693,28 +693,21 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
 
 	ret = of_fsl_espi_get_chipselects(dev);
 	if (ret)
-		goto err;
+		return ret;
 
 	ret = of_address_to_resource(np, 0, &mem);
 	if (ret)
-		goto err;
+		return ret;
 
 	irq = irq_of_parse_and_map(np, 0);
-	if (!irq) {
-		ret = -EINVAL;
-		goto err;
-	}
+	if (!irq)
+		return -EINVAL;
 
 	master = fsl_espi_probe(dev, &mem, irq);
-	if (IS_ERR(master)) {
-		ret = PTR_ERR(master);
-		goto err;
-	}
+	if (IS_ERR(master))
+		return PTR_ERR(master);
 
 	return 0;
-
-err:
-	return ret;
 }
 
 static int of_fsl_espi_remove(struct platform_device *dev)
-- 
2.9.2


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 3/4] spi: fsl-espi: improve return value handling in fsl_espi_probe
       [not found] ` <1d67ce99-42ea-c816-da35-e64575cca8ff-S0/GAf8tV78@public.gmane.org>
  2016-09-17 13:42   ` [PATCH 1/4] spi: fsl-espi: remove unused variable in fsl_espi_setup Heiner Kallweit
  2016-09-17 13:43   ` [PATCH 2/4] spi: fsl-espi: simplify of_fsl_espi_probe Heiner Kallweit
@ 2016-09-17 13:43   ` Heiner Kallweit
       [not found]     ` <dc06d27a-09ed-7720-d86f-9d20134557af-S0/GAf8tV78@public.gmane.org>
  2016-09-17 13:44   ` [PATCH 4/4] spi: fsl-espi: replace of_get_property with of_property_read_u32 Heiner Kallweit
  3 siblings, 1 reply; 11+ messages in thread
From: Heiner Kallweit @ 2016-09-17 13:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

The return value of fsl_espi_probe (currently struct spi_master *)
is just used for checking whether an error occurred.
Change the return value type to int and simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/spi-fsl-espi.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index dee3f82..7451585 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -538,8 +538,8 @@ static size_t fsl_espi_max_message_size(struct spi_device *spi)
 	return SPCOM_TRANLEN_MAX;
 }
 
-static struct spi_master * fsl_espi_probe(struct device *dev,
-		struct resource *mem, unsigned int irq)
+static int fsl_espi_probe(struct device *dev, struct resource *mem,
+			  unsigned int irq)
 {
 	struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
 	struct spi_master *master;
@@ -547,13 +547,11 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
 	struct device_node *nc;
 	const __be32 *prop;
 	u32 regval, csmode;
-	int i, len, ret = 0;
+	int i, len, ret;
 
 	master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi));
-	if (!master) {
-		ret = -ENOMEM;
-		goto err;
-	}
+	if (!master)
+		return -ENOMEM;
 
 	dev_set_drvdata(dev, master);
 
@@ -647,7 +645,7 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
 	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
 
-	return master;
+	return 0;
 
 err_pm:
 	pm_runtime_put_noidle(dev);
@@ -655,8 +653,7 @@ err_pm:
 	pm_runtime_set_suspended(dev);
 err_probe:
 	spi_master_put(master);
-err:
-	return ERR_PTR(ret);
+	return ret;
 }
 
 static int of_fsl_espi_get_chipselects(struct device *dev)
@@ -682,7 +679,6 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
 {
 	struct device *dev = &ofdev->dev;
 	struct device_node *np = ofdev->dev.of_node;
-	struct spi_master *master;
 	struct resource mem;
 	unsigned int irq;
 	int ret;
@@ -703,11 +699,7 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
 	if (!irq)
 		return -EINVAL;
 
-	master = fsl_espi_probe(dev, &mem, irq);
-	if (IS_ERR(master))
-		return PTR_ERR(master);
-
-	return 0;
+	return fsl_espi_probe(dev, &mem, irq);
 }
 
 static int of_fsl_espi_remove(struct platform_device *dev)
-- 
2.9.2


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 4/4] spi: fsl-espi: replace of_get_property with of_property_read_u32
       [not found] ` <1d67ce99-42ea-c816-da35-e64575cca8ff-S0/GAf8tV78@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-09-17 13:43   ` [PATCH 3/4] spi: fsl-espi: improve return value handling in fsl_espi_probe Heiner Kallweit
@ 2016-09-17 13:44   ` Heiner Kallweit
       [not found]     ` <faa8bb6f-a644-5779-6a65-a6d8394bd17f-S0/GAf8tV78@public.gmane.org>
  3 siblings, 1 reply; 11+ messages in thread
From: Heiner Kallweit @ 2016-09-17 13:44 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

Replace of_get_property with of_property_read_u32, thus simplifying
the code and improving readability.

Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/spi-fsl-espi.c | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 7451585..1f97cce 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -545,9 +545,8 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
 	struct spi_master *master;
 	struct mpc8xxx_spi *mpc8xxx_spi;
 	struct device_node *nc;
-	const __be32 *prop;
-	u32 regval, csmode;
-	int i, len, ret;
+	u32 regval, csmode, cs, prop;
+	int ret;
 
 	master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi));
 	if (!master)
@@ -599,29 +598,29 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
 	/* Init eSPI CS mode register */
 	for_each_available_child_of_node(master->dev.of_node, nc) {
 		/* get chip select */
-		prop = of_get_property(nc, "reg", &len);
-		if (!prop || len < sizeof(*prop))
-			continue;
-		i = be32_to_cpup(prop);
-		if (i < 0 || i >= pdata->max_chipselect)
+		ret = of_property_read_u32(nc, "reg", &cs);
+		if (ret || cs >= pdata->max_chipselect)
 			continue;
 
 		csmode = CSMODE_INIT_VAL;
+
 		/* check if CSBEF is set in device tree */
-		prop = of_get_property(nc, "fsl,csbef", &len);
-		if (prop && len >= sizeof(*prop)) {
+		ret = of_property_read_u32(nc, "fsl,csbef", &prop);
+		if (!ret) {
 			csmode &= ~(CSMODE_BEF(0xf));
-			csmode |= CSMODE_BEF(be32_to_cpup(prop));
+			csmode |= CSMODE_BEF(prop);
 		}
+
 		/* check if CSAFT is set in device tree */
-		prop = of_get_property(nc, "fsl,csaft", &len);
-		if (prop && len >= sizeof(*prop)) {
+		ret = of_property_read_u32(nc, "fsl,csaft", &prop);
+		if (!ret) {
 			csmode &= ~(CSMODE_AFT(0xf));
-			csmode |= CSMODE_AFT(be32_to_cpup(prop));
+			csmode |= CSMODE_AFT(prop);
 		}
-		fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPMODEx(i), csmode);
 
-		dev_info(dev, "cs=%d, init_csmode=0x%x\n", i, csmode);
+		fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPMODEx(cs), csmode);
+
+		dev_info(dev, "cs=%u, init_csmode=0x%x\n", cs, csmode);
 	}
 
 	/* Enable SPI interface */
@@ -660,16 +659,16 @@ static int of_fsl_espi_get_chipselects(struct device *dev)
 {
 	struct device_node *np = dev->of_node;
 	struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
-	const u32 *prop;
-	int len;
+	u32 num_cs;
+	int ret;
 
-	prop = of_get_property(np, "fsl,espi-num-chipselects", &len);
-	if (!prop || len < sizeof(*prop)) {
+	ret = of_property_read_u32(np, "fsl,espi-num-chipselects", &num_cs);
+	if (ret) {
 		dev_err(dev, "No 'fsl,espi-num-chipselects' property\n");
 		return -EINVAL;
 	}
 
-	pdata->max_chipselect = *prop;
+	pdata->max_chipselect = num_cs;
 	pdata->cs_control = NULL;
 
 	return 0;
-- 
2.9.2


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/4] spi: fsl-espi: simplify of_fsl_espi_probe
       [not found]     ` <5bfd3921-5bb6-b9c3-dc64-3882491bba13-S0/GAf8tV78@public.gmane.org>
@ 2016-09-24 18:46       ` Mark Brown
  2016-09-25  5:59       ` Applied "spi: fsl-espi: simplify of_fsl_espi_probe" to the spi tree Mark Brown
  1 sibling, 0 replies; 11+ messages in thread
From: Mark Brown @ 2016-09-24 18:46 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 169 bytes --]

On Sat, Sep 17, 2016 at 03:43:00PM +0200, Heiner Kallweit wrote:
> Simplify of_fsl_espi_probe.

In what way is this a simplification?  Please write useful changelogs :(

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

* Applied "spi: fsl-espi: improve return value handling in fsl_espi_probe" to the spi tree
       [not found]     ` <dc06d27a-09ed-7720-d86f-9d20134557af-S0/GAf8tV78@public.gmane.org>
@ 2016-09-25  5:59       ` Mark Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2016-09-25  5:59 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Heiner Kallweit, Mark Brown, Mark Brown,
	linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-spi-u79uwXL29TY76Z2rM5mHXA

The patch

   spi: fsl-espi: improve return value handling in fsl_espi_probe

has been applied to the spi tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 604042af7697314fffb16e266fd7d5ad488439cc Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <heiner.kallweit-S0/GAf8tV78@public.gmane.org>
Date: Sat, 17 Sep 2016 15:43:31 +0200
Subject: [PATCH] spi: fsl-espi: improve return value handling in
 fsl_espi_probe

The return value of fsl_espi_probe (currently struct spi_master *)
is just used for checking whether an error occurred.
Change the return value type to int and simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 drivers/spi/spi-fsl-espi.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index dee3f822cea8..7451585a080e 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -538,8 +538,8 @@ static size_t fsl_espi_max_message_size(struct spi_device *spi)
 	return SPCOM_TRANLEN_MAX;
 }
 
-static struct spi_master * fsl_espi_probe(struct device *dev,
-		struct resource *mem, unsigned int irq)
+static int fsl_espi_probe(struct device *dev, struct resource *mem,
+			  unsigned int irq)
 {
 	struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
 	struct spi_master *master;
@@ -547,13 +547,11 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
 	struct device_node *nc;
 	const __be32 *prop;
 	u32 regval, csmode;
-	int i, len, ret = 0;
+	int i, len, ret;
 
 	master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi));
-	if (!master) {
-		ret = -ENOMEM;
-		goto err;
-	}
+	if (!master)
+		return -ENOMEM;
 
 	dev_set_drvdata(dev, master);
 
@@ -647,7 +645,7 @@ static struct spi_master * fsl_espi_probe(struct device *dev,
 	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
 
-	return master;
+	return 0;
 
 err_pm:
 	pm_runtime_put_noidle(dev);
@@ -655,8 +653,7 @@ err_pm:
 	pm_runtime_set_suspended(dev);
 err_probe:
 	spi_master_put(master);
-err:
-	return ERR_PTR(ret);
+	return ret;
 }
 
 static int of_fsl_espi_get_chipselects(struct device *dev)
@@ -682,7 +679,6 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
 {
 	struct device *dev = &ofdev->dev;
 	struct device_node *np = ofdev->dev.of_node;
-	struct spi_master *master;
 	struct resource mem;
 	unsigned int irq;
 	int ret;
@@ -703,11 +699,7 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
 	if (!irq)
 		return -EINVAL;
 
-	master = fsl_espi_probe(dev, &mem, irq);
-	if (IS_ERR(master))
-		return PTR_ERR(master);
-
-	return 0;
+	return fsl_espi_probe(dev, &mem, irq);
 }
 
 static int of_fsl_espi_remove(struct platform_device *dev)
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Applied "spi: fsl-espi: simplify of_fsl_espi_probe" to the spi tree
       [not found]     ` <5bfd3921-5bb6-b9c3-dc64-3882491bba13-S0/GAf8tV78@public.gmane.org>
  2016-09-24 18:46       ` Mark Brown
@ 2016-09-25  5:59       ` Mark Brown
  1 sibling, 0 replies; 11+ messages in thread
From: Mark Brown @ 2016-09-25  5:59 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Heiner Kallweit, Mark Brown, Mark Brown,
	linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-spi-u79uwXL29TY76Z2rM5mHXA

The patch

   spi: fsl-espi: simplify of_fsl_espi_probe

has been applied to the spi tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From acf692190f972ee2ed6578f30278f21c244d6148 Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <heiner.kallweit-S0/GAf8tV78@public.gmane.org>
Date: Sat, 17 Sep 2016 15:43:00 +0200
Subject: [PATCH] spi: fsl-espi: simplify of_fsl_espi_probe

Simplify of_fsl_espi_probe.

Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 drivers/spi/spi-fsl-espi.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 4f9d9ec6880a..dee3f822cea8 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -685,7 +685,7 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
 	struct spi_master *master;
 	struct resource mem;
 	unsigned int irq;
-	int ret = -ENOMEM;
+	int ret;
 
 	ret = of_mpc8xxx_spi_probe(ofdev);
 	if (ret)
@@ -693,28 +693,21 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
 
 	ret = of_fsl_espi_get_chipselects(dev);
 	if (ret)
-		goto err;
+		return ret;
 
 	ret = of_address_to_resource(np, 0, &mem);
 	if (ret)
-		goto err;
+		return ret;
 
 	irq = irq_of_parse_and_map(np, 0);
-	if (!irq) {
-		ret = -EINVAL;
-		goto err;
-	}
+	if (!irq)
+		return -EINVAL;
 
 	master = fsl_espi_probe(dev, &mem, irq);
-	if (IS_ERR(master)) {
-		ret = PTR_ERR(master);
-		goto err;
-	}
+	if (IS_ERR(master))
+		return PTR_ERR(master);
 
 	return 0;
-
-err:
-	return ret;
 }
 
 static int of_fsl_espi_remove(struct platform_device *dev)
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Applied "spi: fsl-espi: remove unused variable in fsl_espi_setup" to the spi tree
       [not found]     ` <a71abf9f-4254-af63-f7eb-1579faaeada3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-09-25  5:59       ` Mark Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2016-09-25  5:59 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Mark Brown, Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-spi-u79uwXL29TY76Z2rM5mHXA

The patch

   spi: fsl-espi: remove unused variable in fsl_espi_setup

has been applied to the spi tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From fb8ac912df93ea4edc549992d7c9d173e5413164 Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Sat, 17 Sep 2016 15:42:42 +0200
Subject: [PATCH] spi: fsl-espi: remove unused variable in fsl_espi_setup

Remove an unused variable.

Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 drivers/spi/spi-fsl-espi.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index a7984aeede6b..4f9d9ec6880a 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -361,7 +361,6 @@ out:
 static int fsl_espi_setup(struct spi_device *spi)
 {
 	struct mpc8xxx_spi *mpc8xxx_spi;
-	u32 hw_mode;
 	u32 loop_mode;
 	struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi);
 
@@ -379,7 +378,6 @@ static int fsl_espi_setup(struct spi_device *spi)
 
 	pm_runtime_get_sync(mpc8xxx_spi->dev);
 
-	hw_mode = cs->hw_mode; /* Save original settings */
 	cs->hw_mode = fsl_espi_read_reg(mpc8xxx_spi,
 					   ESPI_SPMODEx(spi->chip_select));
 	/* mask out bits we are going to set */
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 4/4] spi: fsl-espi: replace of_get_property with of_property_read_u32
       [not found]     ` <faa8bb6f-a644-5779-6a65-a6d8394bd17f-S0/GAf8tV78@public.gmane.org>
@ 2016-09-27  5:39       ` Heiner Kallweit
       [not found]         ` <10e52aa2-9327-8aa3-0132-74c1feefa165-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2016-10-01 19:07       ` [PATCH v2] " Heiner Kallweit
  1 sibling, 1 reply; 11+ messages in thread
From: Heiner Kallweit @ 2016-09-27  5:39 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

Am 17.09.2016 um 15:44 schrieb Heiner Kallweit:
> Replace of_get_property with of_property_read_u32, thus simplifying
> the code and improving readability.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/spi/spi-fsl-espi.c | 41 ++++++++++++++++++++---------------------
>  1 file changed, 20 insertions(+), 21 deletions(-)
> 
The other three patches of the series you applied already. Any comment
on this one?
Or did your comment on another patch (which you applied nevertheless),
to improve the commit message and better explain the benefit,
actually refer to this one?

> diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
> index 7451585..1f97cce 100644
> --- a/drivers/spi/spi-fsl-espi.c
> +++ b/drivers/spi/spi-fsl-espi.c
> @@ -545,9 +545,8 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
>  	struct spi_master *master;
>  	struct mpc8xxx_spi *mpc8xxx_spi;
>  	struct device_node *nc;
> -	const __be32 *prop;
> -	u32 regval, csmode;
> -	int i, len, ret;
> +	u32 regval, csmode, cs, prop;
> +	int ret;
>  
>  	master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi));
>  	if (!master)
> @@ -599,29 +598,29 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
>  	/* Init eSPI CS mode register */
>  	for_each_available_child_of_node(master->dev.of_node, nc) {
>  		/* get chip select */
> -		prop = of_get_property(nc, "reg", &len);
> -		if (!prop || len < sizeof(*prop))
> -			continue;
> -		i = be32_to_cpup(prop);
> -		if (i < 0 || i >= pdata->max_chipselect)
> +		ret = of_property_read_u32(nc, "reg", &cs);
> +		if (ret || cs >= pdata->max_chipselect)
>  			continue;
>  
>  		csmode = CSMODE_INIT_VAL;
> +
>  		/* check if CSBEF is set in device tree */
> -		prop = of_get_property(nc, "fsl,csbef", &len);
> -		if (prop && len >= sizeof(*prop)) {
> +		ret = of_property_read_u32(nc, "fsl,csbef", &prop);
> +		if (!ret) {
>  			csmode &= ~(CSMODE_BEF(0xf));
> -			csmode |= CSMODE_BEF(be32_to_cpup(prop));
> +			csmode |= CSMODE_BEF(prop);
>  		}
> +
>  		/* check if CSAFT is set in device tree */
> -		prop = of_get_property(nc, "fsl,csaft", &len);
> -		if (prop && len >= sizeof(*prop)) {
> +		ret = of_property_read_u32(nc, "fsl,csaft", &prop);
> +		if (!ret) {
>  			csmode &= ~(CSMODE_AFT(0xf));
> -			csmode |= CSMODE_AFT(be32_to_cpup(prop));
> +			csmode |= CSMODE_AFT(prop);
>  		}
> -		fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPMODEx(i), csmode);
>  
> -		dev_info(dev, "cs=%d, init_csmode=0x%x\n", i, csmode);
> +		fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPMODEx(cs), csmode);
> +
> +		dev_info(dev, "cs=%u, init_csmode=0x%x\n", cs, csmode);
>  	}
>  
>  	/* Enable SPI interface */
> @@ -660,16 +659,16 @@ static int of_fsl_espi_get_chipselects(struct device *dev)
>  {
>  	struct device_node *np = dev->of_node;
>  	struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
> -	const u32 *prop;
> -	int len;
> +	u32 num_cs;
> +	int ret;
>  
> -	prop = of_get_property(np, "fsl,espi-num-chipselects", &len);
> -	if (!prop || len < sizeof(*prop)) {
> +	ret = of_property_read_u32(np, "fsl,espi-num-chipselects", &num_cs);
> +	if (ret) {
>  		dev_err(dev, "No 'fsl,espi-num-chipselects' property\n");
>  		return -EINVAL;
>  	}
>  
> -	pdata->max_chipselect = *prop;
> +	pdata->max_chipselect = num_cs;
>  	pdata->cs_control = NULL;
>  
>  	return 0;
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 4/4] spi: fsl-espi: replace of_get_property with of_property_read_u32
       [not found]         ` <10e52aa2-9327-8aa3-0132-74c1feefa165-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-09-27 16:19           ` Mark Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2016-09-27 16:19 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 885 bytes --]

On Tue, Sep 27, 2016 at 07:39:20AM +0200, Heiner Kallweit wrote:

> The other three patches of the series you applied already. Any comment
> on this one?
> Or did your comment on another patch (which you applied nevertheless),
> to improve the commit message and better explain the benefit,
> actually refer to this one?

I really have no idea, sorry.

Please don't send content free pings and please allow a reasonable time
for review.  People get busy, go on holiday, attend conferences and so 
on so unless there is some reason for urgency (like critical bug fixes)
please allow at least a couple of weeks for review.  If there have been
review comments then people may be waiting for those to be addressed.
Sending content free pings just adds to the mail volume (if they are
seen at all) and if something has gone wrong you'll have to resend the
patches anyway.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

* [PATCH v2] spi: fsl-espi: replace of_get_property with of_property_read_u32
       [not found]     ` <faa8bb6f-a644-5779-6a65-a6d8394bd17f-S0/GAf8tV78@public.gmane.org>
  2016-09-27  5:39       ` Heiner Kallweit
@ 2016-10-01 19:07       ` Heiner Kallweit
  1 sibling, 0 replies; 11+ messages in thread
From: Heiner Kallweit @ 2016-10-01 19:07 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

of_property_read_u32 is better here than generic of_get_property:
- implicit endianness conversion if needed
- implicit checking of size of property

Signed-off-by: Heiner Kallweit <hkallweit1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
v2:
- improved commit message
---
 drivers/spi/spi-fsl-espi.c | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 7451585..1f97cce 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -545,9 +545,8 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
 	struct spi_master *master;
 	struct mpc8xxx_spi *mpc8xxx_spi;
 	struct device_node *nc;
-	const __be32 *prop;
-	u32 regval, csmode;
-	int i, len, ret;
+	u32 regval, csmode, cs, prop;
+	int ret;
 
 	master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi));
 	if (!master)
@@ -599,29 +598,29 @@ static int fsl_espi_probe(struct device *dev, struct resource *mem,
 	/* Init eSPI CS mode register */
 	for_each_available_child_of_node(master->dev.of_node, nc) {
 		/* get chip select */
-		prop = of_get_property(nc, "reg", &len);
-		if (!prop || len < sizeof(*prop))
-			continue;
-		i = be32_to_cpup(prop);
-		if (i < 0 || i >= pdata->max_chipselect)
+		ret = of_property_read_u32(nc, "reg", &cs);
+		if (ret || cs >= pdata->max_chipselect)
 			continue;
 
 		csmode = CSMODE_INIT_VAL;
+
 		/* check if CSBEF is set in device tree */
-		prop = of_get_property(nc, "fsl,csbef", &len);
-		if (prop && len >= sizeof(*prop)) {
+		ret = of_property_read_u32(nc, "fsl,csbef", &prop);
+		if (!ret) {
 			csmode &= ~(CSMODE_BEF(0xf));
-			csmode |= CSMODE_BEF(be32_to_cpup(prop));
+			csmode |= CSMODE_BEF(prop);
 		}
+
 		/* check if CSAFT is set in device tree */
-		prop = of_get_property(nc, "fsl,csaft", &len);
-		if (prop && len >= sizeof(*prop)) {
+		ret = of_property_read_u32(nc, "fsl,csaft", &prop);
+		if (!ret) {
 			csmode &= ~(CSMODE_AFT(0xf));
-			csmode |= CSMODE_AFT(be32_to_cpup(prop));
+			csmode |= CSMODE_AFT(prop);
 		}
-		fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPMODEx(i), csmode);
 
-		dev_info(dev, "cs=%d, init_csmode=0x%x\n", i, csmode);
+		fsl_espi_write_reg(mpc8xxx_spi, ESPI_SPMODEx(cs), csmode);
+
+		dev_info(dev, "cs=%u, init_csmode=0x%x\n", cs, csmode);
 	}
 
 	/* Enable SPI interface */
@@ -660,16 +659,16 @@ static int of_fsl_espi_get_chipselects(struct device *dev)
 {
 	struct device_node *np = dev->of_node;
 	struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
-	const u32 *prop;
-	int len;
+	u32 num_cs;
+	int ret;
 
-	prop = of_get_property(np, "fsl,espi-num-chipselects", &len);
-	if (!prop || len < sizeof(*prop)) {
+	ret = of_property_read_u32(np, "fsl,espi-num-chipselects", &num_cs);
+	if (ret) {
 		dev_err(dev, "No 'fsl,espi-num-chipselects' property\n");
 		return -EINVAL;
 	}
 
-	pdata->max_chipselect = *prop;
+	pdata->max_chipselect = num_cs;
 	pdata->cs_control = NULL;
 
 	return 0;
-- 
2.9.2


--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2016-10-01 19:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1d67ce99-42ea-c816-da35-e64575cca8ff@web.de>
     [not found] ` <1d67ce99-42ea-c816-da35-e64575cca8ff-S0/GAf8tV78@public.gmane.org>
2016-09-17 13:42   ` [PATCH 1/4] spi: fsl-espi: remove unused variable in fsl_espi_setup Heiner Kallweit
     [not found]     ` <a71abf9f-4254-af63-f7eb-1579faaeada3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-25  5:59       ` Applied "spi: fsl-espi: remove unused variable in fsl_espi_setup" to the spi tree Mark Brown
2016-09-17 13:43   ` [PATCH 2/4] spi: fsl-espi: simplify of_fsl_espi_probe Heiner Kallweit
     [not found]     ` <5bfd3921-5bb6-b9c3-dc64-3882491bba13-S0/GAf8tV78@public.gmane.org>
2016-09-24 18:46       ` Mark Brown
2016-09-25  5:59       ` Applied "spi: fsl-espi: simplify of_fsl_espi_probe" to the spi tree Mark Brown
2016-09-17 13:43   ` [PATCH 3/4] spi: fsl-espi: improve return value handling in fsl_espi_probe Heiner Kallweit
     [not found]     ` <dc06d27a-09ed-7720-d86f-9d20134557af-S0/GAf8tV78@public.gmane.org>
2016-09-25  5:59       ` Applied "spi: fsl-espi: improve return value handling in fsl_espi_probe" to the spi tree Mark Brown
2016-09-17 13:44   ` [PATCH 4/4] spi: fsl-espi: replace of_get_property with of_property_read_u32 Heiner Kallweit
     [not found]     ` <faa8bb6f-a644-5779-6a65-a6d8394bd17f-S0/GAf8tV78@public.gmane.org>
2016-09-27  5:39       ` Heiner Kallweit
     [not found]         ` <10e52aa2-9327-8aa3-0132-74c1feefa165-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-27 16:19           ` Mark Brown
2016-10-01 19:07       ` [PATCH v2] " Heiner Kallweit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.