All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-12  9:10 Varka Bhadram
  2014-06-12 18:03 ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: Varka Bhadram @ 2014-06-12  9:10 UTC (permalink / raw)
  To: netdev
  Cc: alex.bluesman.smirnov, dbaryshkov, linux-zigbee-devel,
	linux-kernel, davem, Varka Bhadram

separate the mrf24j40 hardware initialisation from probe()
and adds the sanity checkings.

These checkings are required if somebody hasn't a right spi configuration 
the probe function should fail. So we have to return from there.

Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
 drivers/net/ieee802154/mrf24j40.c |  114 +++++++++++++++++++++++++++++--------
 1 file changed, 89 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index 4048062..9574d10 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -610,6 +610,92 @@ out:
 	return IRQ_HANDLED;
 }
 
+static int mrf24j40_hw_init(struct mrf24j40 *devrec)
+{
+	int ret;
+	u8 val;
+
+	/* Initialize the device.
+		From datasheet section 3.2: Initialization. */
+	ret = write_short_reg(devrec, REG_SOFTRST, 0x07);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_PACON2, 0x98);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_TXSTBL, 0x95);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON0, 0x03);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON1, 0x01);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON6, 0x90);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON7, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON8, 0x10);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_SLPCON1, 0x21);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_CCAEDTH, 0x60);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG6, 0x40);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x04);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x0);
+	if (ret)
+		goto err_ret;
+
+	udelay(192);
+
+	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
+	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	if (ret)
+		goto err_ret;
+
+	val &= ~0x3; /* Clear RX mode (normal) */
+
+	ret = write_short_reg(devrec, REG_RXMCR, val);
+	if (ret)
+		goto err_ret;
+
+	return 0;
+
+err_ret:
+	return ret;
+}
+
 static int mrf24j40_probe(struct spi_device *spi)
 {
 	int ret = -ENOMEM;
@@ -650,31 +736,9 @@ static int mrf24j40_probe(struct spi_device *spi)
 	if (ret)
 		goto err_register_device;
 
-	/* Initialize the device.
-		From datasheet section 3.2: Initialization. */
-	write_short_reg(devrec, REG_SOFTRST, 0x07);
-	write_short_reg(devrec, REG_PACON2, 0x98);
-	write_short_reg(devrec, REG_TXSTBL, 0x95);
-	write_long_reg(devrec, REG_RFCON0, 0x03);
-	write_long_reg(devrec, REG_RFCON1, 0x01);
-	write_long_reg(devrec, REG_RFCON2, 0x80);
-	write_long_reg(devrec, REG_RFCON6, 0x90);
-	write_long_reg(devrec, REG_RFCON7, 0x80);
-	write_long_reg(devrec, REG_RFCON8, 0x10);
-	write_long_reg(devrec, REG_SLPCON1, 0x21);
-	write_short_reg(devrec, REG_BBREG2, 0x80);
-	write_short_reg(devrec, REG_CCAEDTH, 0x60);
-	write_short_reg(devrec, REG_BBREG6, 0x40);
-	write_short_reg(devrec, REG_RFCTL, 0x04);
-	write_short_reg(devrec, REG_RFCTL, 0x0);
-	udelay(192);
-
-	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
-	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	ret = mrf24j40_hw_init(devrec);
 	if (ret)
-		goto err_read_reg;
-	val &= ~0x3; /* Clear RX mode (normal) */
-	write_short_reg(devrec, REG_RXMCR, val);
+		return err_hw_init;
 
 	ret = devm_request_threaded_irq(&spi->dev,
 					spi->irq,
@@ -692,7 +756,7 @@ static int mrf24j40_probe(struct spi_device *spi)
 	return 0;
 
 err_irq:
-err_read_reg:
+err_hw_init:
 	ieee802154_unregister_device(devrec->dev);
 err_register_device:
 	ieee802154_free_device(devrec->dev);
-- 
1.7.9.5


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

* Re: [PATCH net-next] mrf24j40: separate h/w init and add checkings
  2014-06-12  9:10 [PATCH net-next] mrf24j40: separate h/w init and add checkings Varka Bhadram
@ 2014-06-12 18:03 ` David Miller
  2014-06-12 18:05     ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2014-06-12 18:03 UTC (permalink / raw)
  To: varkabhadram
  Cc: netdev, alex.bluesman.smirnov, dbaryshkov, linux-zigbee-devel,
	linux-kernel, varkab

From: Varka Bhadram <varkabhadram@gmail.com>
Date: Thu, 12 Jun 2014 14:40:48 +0530

> separate the mrf24j40 hardware initialisation from probe()
> and adds the sanity checkings.
> 
> These checkings are required if somebody hasn't a right spi configuration 
> the probe function should fail. So we have to return from there.
> 
> Signed-off-by: Varka Bhadram <varkab@cdac.in>

Applied, thanks.

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

* Re: [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-12 18:05     ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2014-06-12 18:05 UTC (permalink / raw)
  To: varkabhadram
  Cc: netdev, alex.bluesman.smirnov, dbaryshkov, linux-zigbee-devel,
	linux-kernel, varkab

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: Text/Plain; charset=iso-8859-7, Size: 1316 bytes --]

From: David Miller <davem@davemloft.net>
Date: Thu, 12 Jun 2014 11:03:24 -0700 (PDT)

> From: Varka Bhadram <varkabhadram@gmail.com>
> Date: Thu, 12 Jun 2014 14:40:48 +0530
> 
>> separate the mrf24j40 hardware initialisation from probe()
>> and adds the sanity checkings.
>> 
>> These checkings are required if somebody hasn't a right spi configuration 
>> the probe function should fail. So we have to return from there.
>> 
>> Signed-off-by: Varka Bhadram <varkab@cdac.in>
> 
> Applied, thanks.

Reverted, did you even compile test this change?

drivers/net/ieee802154/mrf24j40.c: In function ¡mrf24j40_probe¢:
drivers/net/ieee802154/mrf24j40.c:741:10: error: ¡err_hw_init¢ undeclared (first use in this function)
drivers/net/ieee802154/mrf24j40.c:741:10: note: each undeclared identifier is reported only once for each function it appears in
drivers/net/ieee802154/mrf24j40.c:759:1: warning: label ¡err_hw_init¢ defined but not used [-Wunused-label]
drivers/net/ieee802154/mrf24j40.c:702:5: warning: unused variable ¡val¢ [-Wunused-variable]
make[1]: *** [drivers/net/ieee802154/mrf24j40.o] Error 1
make: *** [drivers/net/ieee802154/mrf24j40.o] Error 2
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-12 18:05     ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2014-06-12 18:05 UTC (permalink / raw)
  To: varkabhadram-Re5JQEeQqe8AvxtiuMwx3w
  Cc: varkab-If5XQcfNmg0, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

From: David Miller <davem@davemloft.net>
Date: Thu, 12 Jun 2014 11:03:24 -0700 (PDT)

> From: Varka Bhadram <varkabhadram@gmail.com>
> Date: Thu, 12 Jun 2014 14:40:48 +0530
> 
>> separate the mrf24j40 hardware initialisation from probe()
>> and adds the sanity checkings.
>> 
>> These checkings are required if somebody hasn't a right spi configuration 
>> the probe function should fail. So we have to return from there.
>> 
>> Signed-off-by: Varka Bhadram <varkab@cdac.in>
> 
> Applied, thanks.

Reverted, did you even compile test this change?

drivers/net/ieee802154/mrf24j40.c: In function ‘mrf24j40_probe’:
drivers/net/ieee802154/mrf24j40.c:741:10: error: ‘err_hw_init’ undeclared (first use in this function)
drivers/net/ieee802154/mrf24j40.c:741:10: note: each undeclared identifier is reported only once for each function it appears in
drivers/net/ieee802154/mrf24j40.c:759:1: warning: label ‘err_hw_init’ defined but not used [-Wunused-label]
drivers/net/ieee802154/mrf24j40.c:702:5: warning: unused variable ‘val’ [-Wunused-variable]
make[1]: *** [drivers/net/ieee802154/mrf24j40.o] Error 1
make: *** [drivers/net/ieee802154/mrf24j40.o] Error 2
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

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

* Re: [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-13  3:36       ` Varka Bhadram
  0 siblings, 0 replies; 12+ messages in thread
From: Varka Bhadram @ 2014-06-13  3:36 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Alexander Smirnov, Dmitry Eremin-Solenikov,
	linux-zigbee-devel, linux-kernel, Varka Bhadram

Hi David,

Sorry for the noise. i will send the fixed patch.

Thanks.

-Varka Bhadram

On Thu, Jun 12, 2014 at 11:35 PM, David Miller <davem@davemloft.net> wrote:
> From: David Miller <davem@davemloft.net>
> Date: Thu, 12 Jun 2014 11:03:24 -0700 (PDT)
>
>> From: Varka Bhadram <varkabhadram@gmail.com>
>> Date: Thu, 12 Jun 2014 14:40:48 +0530
>>
>>> separate the mrf24j40 hardware initialisation from probe()
>>> and adds the sanity checkings.
>>>
>>> These checkings are required if somebody hasn't a right spi configuration
>>> the probe function should fail. So we have to return from there.
>>>
>>> Signed-off-by: Varka Bhadram <varkab@cdac.in>
>>
>> Applied, thanks.
>
> Reverted, did you even compile test this change?
>
> drivers/net/ieee802154/mrf24j40.c: In function ‘mrf24j40_probe’:
> drivers/net/ieee802154/mrf24j40.c:741:10: error: ‘err_hw_init’ undeclared (first use in this function)
> drivers/net/ieee802154/mrf24j40.c:741:10: note: each undeclared identifier is reported only once for each function it appears in
> drivers/net/ieee802154/mrf24j40.c:759:1: warning: label ‘err_hw_init’ defined but not used [-Wunused-label]
> drivers/net/ieee802154/mrf24j40.c:702:5: warning: unused variable ‘val’ [-Wunused-variable]
> make[1]: *** [drivers/net/ieee802154/mrf24j40.o] Error 1
> make: *** [drivers/net/ieee802154/mrf24j40.o] Error 2

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

* Re: [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-13  3:36       ` Varka Bhadram
  0 siblings, 0 replies; 12+ messages in thread
From: Varka Bhadram @ 2014-06-13  3:36 UTC (permalink / raw)
  To: David Miller
  Cc: Varka Bhadram, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi David,

Sorry for the noise. i will send the fixed patch.

Thanks.

-Varka Bhadram

On Thu, Jun 12, 2014 at 11:35 PM, David Miller <davem@davemloft.net> wrote:
> From: David Miller <davem@davemloft.net>
> Date: Thu, 12 Jun 2014 11:03:24 -0700 (PDT)
>
>> From: Varka Bhadram <varkabhadram@gmail.com>
>> Date: Thu, 12 Jun 2014 14:40:48 +0530
>>
>>> separate the mrf24j40 hardware initialisation from probe()
>>> and adds the sanity checkings.
>>>
>>> These checkings are required if somebody hasn't a right spi configuration
>>> the probe function should fail. So we have to return from there.
>>>
>>> Signed-off-by: Varka Bhadram <varkab@cdac.in>
>>
>> Applied, thanks.
>
> Reverted, did you even compile test this change?
>
> drivers/net/ieee802154/mrf24j40.c: In function ‘mrf24j40_probe’:
> drivers/net/ieee802154/mrf24j40.c:741:10: error: ‘err_hw_init’ undeclared (first use in this function)
> drivers/net/ieee802154/mrf24j40.c:741:10: note: each undeclared identifier is reported only once for each function it appears in
> drivers/net/ieee802154/mrf24j40.c:759:1: warning: label ‘err_hw_init’ defined but not used [-Wunused-label]
> drivers/net/ieee802154/mrf24j40.c:702:5: warning: unused variable ‘val’ [-Wunused-variable]
> make[1]: *** [drivers/net/ieee802154/mrf24j40.o] Error 1
> make: *** [drivers/net/ieee802154/mrf24j40.o] Error 2

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

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

* Re: [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-17 22:31   ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2014-06-17 22:31 UTC (permalink / raw)
  To: varkabhadram
  Cc: netdev, alex.bluesman.smirnov, dbaryshkov, linux-zigbee-devel,
	linux-kernel, varkab

From: Varka Bhadram <varkabhadram@gmail.com>
Date: Mon, 16 Jun 2014 09:12:31 +0530

> separate the mrf24j40 hardware initialisation from probe()
> and adds the sanity checkings.
> 
> These checkings are required if somebody hasn't a right spi configuration
> the probe function should fail. So we have to return from there.
> 
> Signed-off-by: Varka Bhadram <varkab@cdac.in>

Applied.

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

* Re: [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-17 22:31   ` David Miller
  0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2014-06-17 22:31 UTC (permalink / raw)
  To: varkabhadram-Re5JQEeQqe8AvxtiuMwx3w
  Cc: varkab-If5XQcfNmg0, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

From: Varka Bhadram <varkabhadram-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Mon, 16 Jun 2014 09:12:31 +0530

> separate the mrf24j40 hardware initialisation from probe()
> and adds the sanity checkings.
> 
> These checkings are required if somebody hasn't a right spi configuration
> the probe function should fail. So we have to return from there.
> 
> Signed-off-by: Varka Bhadram <varkab-If5XQcfNmg0@public.gmane.org>

Applied.

------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems

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

* [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-16  3:42 ` Varka Bhadram
  0 siblings, 0 replies; 12+ messages in thread
From: Varka Bhadram @ 2014-06-16  3:42 UTC (permalink / raw)
  To: netdev
  Cc: alex.bluesman.smirnov, dbaryshkov, linux-zigbee-devel,
	linux-kernel, davem, Varka Bhadram

separate the mrf24j40 hardware initialisation from probe()
and adds the sanity checkings.

These checkings are required if somebody hasn't a right spi configuration
the probe function should fail. So we have to return from there.

Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
 drivers/net/ieee802154/mrf24j40.c |  115 ++++++++++++++++++++++++++++---------
 1 file changed, 89 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index 4048062..9e6a124 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -610,10 +610,95 @@ out:
 	return IRQ_HANDLED;
 }
 
+static int mrf24j40_hw_init(struct mrf24j40 *devrec)
+{
+	int ret;
+	u8 val;
+
+	/* Initialize the device.
+		From datasheet section 3.2: Initialization. */
+	ret = write_short_reg(devrec, REG_SOFTRST, 0x07);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_PACON2, 0x98);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_TXSTBL, 0x95);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON0, 0x03);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON1, 0x01);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON6, 0x90);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON7, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON8, 0x10);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_SLPCON1, 0x21);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_CCAEDTH, 0x60);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG6, 0x40);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x04);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x0);
+	if (ret)
+		goto err_ret;
+
+	udelay(192);
+
+	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
+	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	if (ret)
+		goto err_ret;
+
+	val &= ~0x3; /* Clear RX mode (normal) */
+
+	ret = write_short_reg(devrec, REG_RXMCR, val);
+	if (ret)
+		goto err_ret;
+
+	return 0;
+
+err_ret:
+	return ret;
+}
+
 static int mrf24j40_probe(struct spi_device *spi)
 {
 	int ret = -ENOMEM;
-	u8 val;
 	struct mrf24j40 *devrec;
 
 	printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq);
@@ -650,31 +735,9 @@ static int mrf24j40_probe(struct spi_device *spi)
 	if (ret)
 		goto err_register_device;
 
-	/* Initialize the device.
-		From datasheet section 3.2: Initialization. */
-	write_short_reg(devrec, REG_SOFTRST, 0x07);
-	write_short_reg(devrec, REG_PACON2, 0x98);
-	write_short_reg(devrec, REG_TXSTBL, 0x95);
-	write_long_reg(devrec, REG_RFCON0, 0x03);
-	write_long_reg(devrec, REG_RFCON1, 0x01);
-	write_long_reg(devrec, REG_RFCON2, 0x80);
-	write_long_reg(devrec, REG_RFCON6, 0x90);
-	write_long_reg(devrec, REG_RFCON7, 0x80);
-	write_long_reg(devrec, REG_RFCON8, 0x10);
-	write_long_reg(devrec, REG_SLPCON1, 0x21);
-	write_short_reg(devrec, REG_BBREG2, 0x80);
-	write_short_reg(devrec, REG_CCAEDTH, 0x60);
-	write_short_reg(devrec, REG_BBREG6, 0x40);
-	write_short_reg(devrec, REG_RFCTL, 0x04);
-	write_short_reg(devrec, REG_RFCTL, 0x0);
-	udelay(192);
-
-	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
-	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	ret = mrf24j40_hw_init(devrec);
 	if (ret)
-		goto err_read_reg;
-	val &= ~0x3; /* Clear RX mode (normal) */
-	write_short_reg(devrec, REG_RXMCR, val);
+		goto err_hw_init;
 
 	ret = devm_request_threaded_irq(&spi->dev,
 					spi->irq,
@@ -692,7 +755,7 @@ static int mrf24j40_probe(struct spi_device *spi)
 	return 0;
 
 err_irq:
-err_read_reg:
+err_hw_init:
 	ieee802154_unregister_device(devrec->dev);
 err_register_device:
 	ieee802154_free_device(devrec->dev);
-- 
1.7.9.5


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

* [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-16  3:42 ` Varka Bhadram
  0 siblings, 0 replies; 12+ messages in thread
From: Varka Bhadram @ 2014-06-16  3:42 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: Varka Bhadram, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q

separate the mrf24j40 hardware initialisation from probe()
and adds the sanity checkings.

These checkings are required if somebody hasn't a right spi configuration
the probe function should fail. So we have to return from there.

Signed-off-by: Varka Bhadram <varkab-If5XQcfNmg0@public.gmane.org>
---
 drivers/net/ieee802154/mrf24j40.c |  115 ++++++++++++++++++++++++++++---------
 1 file changed, 89 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index 4048062..9e6a124 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -610,10 +610,95 @@ out:
 	return IRQ_HANDLED;
 }
 
+static int mrf24j40_hw_init(struct mrf24j40 *devrec)
+{
+	int ret;
+	u8 val;
+
+	/* Initialize the device.
+		From datasheet section 3.2: Initialization. */
+	ret = write_short_reg(devrec, REG_SOFTRST, 0x07);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_PACON2, 0x98);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_TXSTBL, 0x95);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON0, 0x03);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON1, 0x01);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON6, 0x90);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON7, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON8, 0x10);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_SLPCON1, 0x21);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_CCAEDTH, 0x60);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG6, 0x40);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x04);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x0);
+	if (ret)
+		goto err_ret;
+
+	udelay(192);
+
+	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
+	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	if (ret)
+		goto err_ret;
+
+	val &= ~0x3; /* Clear RX mode (normal) */
+
+	ret = write_short_reg(devrec, REG_RXMCR, val);
+	if (ret)
+		goto err_ret;
+
+	return 0;
+
+err_ret:
+	return ret;
+}
+
 static int mrf24j40_probe(struct spi_device *spi)
 {
 	int ret = -ENOMEM;
-	u8 val;
 	struct mrf24j40 *devrec;
 
 	printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq);
@@ -650,31 +735,9 @@ static int mrf24j40_probe(struct spi_device *spi)
 	if (ret)
 		goto err_register_device;
 
-	/* Initialize the device.
-		From datasheet section 3.2: Initialization. */
-	write_short_reg(devrec, REG_SOFTRST, 0x07);
-	write_short_reg(devrec, REG_PACON2, 0x98);
-	write_short_reg(devrec, REG_TXSTBL, 0x95);
-	write_long_reg(devrec, REG_RFCON0, 0x03);
-	write_long_reg(devrec, REG_RFCON1, 0x01);
-	write_long_reg(devrec, REG_RFCON2, 0x80);
-	write_long_reg(devrec, REG_RFCON6, 0x90);
-	write_long_reg(devrec, REG_RFCON7, 0x80);
-	write_long_reg(devrec, REG_RFCON8, 0x10);
-	write_long_reg(devrec, REG_SLPCON1, 0x21);
-	write_short_reg(devrec, REG_BBREG2, 0x80);
-	write_short_reg(devrec, REG_CCAEDTH, 0x60);
-	write_short_reg(devrec, REG_BBREG6, 0x40);
-	write_short_reg(devrec, REG_RFCTL, 0x04);
-	write_short_reg(devrec, REG_RFCTL, 0x0);
-	udelay(192);
-
-	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
-	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	ret = mrf24j40_hw_init(devrec);
 	if (ret)
-		goto err_read_reg;
-	val &= ~0x3; /* Clear RX mode (normal) */
-	write_short_reg(devrec, REG_RXMCR, val);
+		goto err_hw_init;
 
 	ret = devm_request_threaded_irq(&spi->dev,
 					spi->irq,
@@ -692,7 +755,7 @@ static int mrf24j40_probe(struct spi_device *spi)
 	return 0;
 
 err_irq:
-err_read_reg:
+err_hw_init:
 	ieee802154_unregister_device(devrec->dev);
 err_register_device:
 	ieee802154_free_device(devrec->dev);
-- 
1.7.9.5


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems

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

* [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-13  3:57 ` Varka Bhadram
  0 siblings, 0 replies; 12+ messages in thread
From: Varka Bhadram @ 2014-06-13  3:57 UTC (permalink / raw)
  To: netdev
  Cc: alex.bluesman.smirnov, dbaryshkov, linux-zigbee-devel,
	linux-kernel, davem, Varka Bhadram

separate the mrf24j40 hardware initialisation from probe()
and adds the sanity checkings.

These checkings are required if somebody hasn't a right spi configuration
the probe function should fail. So we have to return from there.

Signed-off-by: Varka Bhadram <varkab@cdac.in>
---
 drivers/net/ieee802154/mrf24j40.c |  115 ++++++++++++++++++++++++++++---------
 1 file changed, 89 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index 4048062..9e6a124 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -610,10 +610,95 @@ out:
 	return IRQ_HANDLED;
 }
 
+static int mrf24j40_hw_init(struct mrf24j40 *devrec)
+{
+	int ret;
+	u8 val;
+
+	/* Initialize the device.
+		From datasheet section 3.2: Initialization. */
+	ret = write_short_reg(devrec, REG_SOFTRST, 0x07);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_PACON2, 0x98);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_TXSTBL, 0x95);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON0, 0x03);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON1, 0x01);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON6, 0x90);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON7, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON8, 0x10);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_SLPCON1, 0x21);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_CCAEDTH, 0x60);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG6, 0x40);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x04);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x0);
+	if (ret)
+		goto err_ret;
+
+	udelay(192);
+
+	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
+	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	if (ret)
+		goto err_ret;
+
+	val &= ~0x3; /* Clear RX mode (normal) */
+
+	ret = write_short_reg(devrec, REG_RXMCR, val);
+	if (ret)
+		goto err_ret;
+
+	return 0;
+
+err_ret:
+	return ret;
+}
+
 static int mrf24j40_probe(struct spi_device *spi)
 {
 	int ret = -ENOMEM;
-	u8 val;
 	struct mrf24j40 *devrec;
 
 	printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq);
@@ -650,31 +735,9 @@ static int mrf24j40_probe(struct spi_device *spi)
 	if (ret)
 		goto err_register_device;
 
-	/* Initialize the device.
-		From datasheet section 3.2: Initialization. */
-	write_short_reg(devrec, REG_SOFTRST, 0x07);
-	write_short_reg(devrec, REG_PACON2, 0x98);
-	write_short_reg(devrec, REG_TXSTBL, 0x95);
-	write_long_reg(devrec, REG_RFCON0, 0x03);
-	write_long_reg(devrec, REG_RFCON1, 0x01);
-	write_long_reg(devrec, REG_RFCON2, 0x80);
-	write_long_reg(devrec, REG_RFCON6, 0x90);
-	write_long_reg(devrec, REG_RFCON7, 0x80);
-	write_long_reg(devrec, REG_RFCON8, 0x10);
-	write_long_reg(devrec, REG_SLPCON1, 0x21);
-	write_short_reg(devrec, REG_BBREG2, 0x80);
-	write_short_reg(devrec, REG_CCAEDTH, 0x60);
-	write_short_reg(devrec, REG_BBREG6, 0x40);
-	write_short_reg(devrec, REG_RFCTL, 0x04);
-	write_short_reg(devrec, REG_RFCTL, 0x0);
-	udelay(192);
-
-	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
-	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	ret = mrf24j40_hw_init(devrec);
 	if (ret)
-		goto err_read_reg;
-	val &= ~0x3; /* Clear RX mode (normal) */
-	write_short_reg(devrec, REG_RXMCR, val);
+		goto err_hw_init;
 
 	ret = devm_request_threaded_irq(&spi->dev,
 					spi->irq,
@@ -692,7 +755,7 @@ static int mrf24j40_probe(struct spi_device *spi)
 	return 0;
 
 err_irq:
-err_read_reg:
+err_hw_init:
 	ieee802154_unregister_device(devrec->dev);
 err_register_device:
 	ieee802154_free_device(devrec->dev);
-- 
1.7.9.5


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

* [PATCH net-next] mrf24j40: separate h/w init and add checkings
@ 2014-06-13  3:57 ` Varka Bhadram
  0 siblings, 0 replies; 12+ messages in thread
From: Varka Bhadram @ 2014-06-13  3:57 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: Varka Bhadram, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q

separate the mrf24j40 hardware initialisation from probe()
and adds the sanity checkings.

These checkings are required if somebody hasn't a right spi configuration
the probe function should fail. So we have to return from there.

Signed-off-by: Varka Bhadram <varkab-If5XQcfNmg0@public.gmane.org>
---
 drivers/net/ieee802154/mrf24j40.c |  115 ++++++++++++++++++++++++++++---------
 1 file changed, 89 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index 4048062..9e6a124 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -610,10 +610,95 @@ out:
 	return IRQ_HANDLED;
 }
 
+static int mrf24j40_hw_init(struct mrf24j40 *devrec)
+{
+	int ret;
+	u8 val;
+
+	/* Initialize the device.
+		From datasheet section 3.2: Initialization. */
+	ret = write_short_reg(devrec, REG_SOFTRST, 0x07);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_PACON2, 0x98);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_TXSTBL, 0x95);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON0, 0x03);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON1, 0x01);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON6, 0x90);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON7, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_RFCON8, 0x10);
+	if (ret)
+		goto err_ret;
+
+	ret = write_long_reg(devrec, REG_SLPCON1, 0x21);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG2, 0x80);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_CCAEDTH, 0x60);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_BBREG6, 0x40);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x04);
+	if (ret)
+		goto err_ret;
+
+	ret = write_short_reg(devrec, REG_RFCTL, 0x0);
+	if (ret)
+		goto err_ret;
+
+	udelay(192);
+
+	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
+	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	if (ret)
+		goto err_ret;
+
+	val &= ~0x3; /* Clear RX mode (normal) */
+
+	ret = write_short_reg(devrec, REG_RXMCR, val);
+	if (ret)
+		goto err_ret;
+
+	return 0;
+
+err_ret:
+	return ret;
+}
+
 static int mrf24j40_probe(struct spi_device *spi)
 {
 	int ret = -ENOMEM;
-	u8 val;
 	struct mrf24j40 *devrec;
 
 	printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq);
@@ -650,31 +735,9 @@ static int mrf24j40_probe(struct spi_device *spi)
 	if (ret)
 		goto err_register_device;
 
-	/* Initialize the device.
-		From datasheet section 3.2: Initialization. */
-	write_short_reg(devrec, REG_SOFTRST, 0x07);
-	write_short_reg(devrec, REG_PACON2, 0x98);
-	write_short_reg(devrec, REG_TXSTBL, 0x95);
-	write_long_reg(devrec, REG_RFCON0, 0x03);
-	write_long_reg(devrec, REG_RFCON1, 0x01);
-	write_long_reg(devrec, REG_RFCON2, 0x80);
-	write_long_reg(devrec, REG_RFCON6, 0x90);
-	write_long_reg(devrec, REG_RFCON7, 0x80);
-	write_long_reg(devrec, REG_RFCON8, 0x10);
-	write_long_reg(devrec, REG_SLPCON1, 0x21);
-	write_short_reg(devrec, REG_BBREG2, 0x80);
-	write_short_reg(devrec, REG_CCAEDTH, 0x60);
-	write_short_reg(devrec, REG_BBREG6, 0x40);
-	write_short_reg(devrec, REG_RFCTL, 0x04);
-	write_short_reg(devrec, REG_RFCTL, 0x0);
-	udelay(192);
-
-	/* Set RX Mode. RXMCR<1:0>: 0x0 normal, 0x1 promisc, 0x2 error */
-	ret = read_short_reg(devrec, REG_RXMCR, &val);
+	ret = mrf24j40_hw_init(devrec);
 	if (ret)
-		goto err_read_reg;
-	val &= ~0x3; /* Clear RX mode (normal) */
-	write_short_reg(devrec, REG_RXMCR, val);
+		goto err_hw_init;
 
 	ret = devm_request_threaded_irq(&spi->dev,
 					spi->irq,
@@ -692,7 +755,7 @@ static int mrf24j40_probe(struct spi_device *spi)
 	return 0;
 
 err_irq:
-err_read_reg:
+err_hw_init:
 	ieee802154_unregister_device(devrec->dev);
 err_register_device:
 	ieee802154_free_device(devrec->dev);
-- 
1.7.9.5


------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems

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

end of thread, other threads:[~2014-06-17 22:31 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12  9:10 [PATCH net-next] mrf24j40: separate h/w init and add checkings Varka Bhadram
2014-06-12 18:03 ` David Miller
2014-06-12 18:05   ` David Miller
2014-06-12 18:05     ` David Miller
2014-06-13  3:36     ` Varka Bhadram
2014-06-13  3:36       ` Varka Bhadram
2014-06-13  3:57 Varka Bhadram
2014-06-13  3:57 ` Varka Bhadram
2014-06-16  3:42 Varka Bhadram
2014-06-16  3:42 ` Varka Bhadram
2014-06-17 22:31 ` David Miller
2014-06-17 22:31   ` David Miller

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.