Skip to contentSkip to conversation

Fixes and cleanup for CC2520

PATCH In review Varka Bhadram 2 participants 5 messages Dec 26, 2014 – Dec 30, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Fixes and cleanup for CC2520

This series will introduce some cleanup code and fix for having zero perm_extended_addr address.

Varka Bhadram (3):
cc2520: use devm_kzalloc(.., sizeof(*pointer), ..) pattern
cc2520: remove 'ret' goto label
cc2520: fix zero perm_extended_addr address

 drivers/net/ieee802154/cc2520.c |   18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/3 cc2520: use devm_kzalloc(.., sizeof(*pointer), ..) pattern

---
 drivers/net/ieee802154/cc2520.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ieee802154/cc2520.c +1 -2
index c2b7da3..c2e725e 100644
@@ -845,8 +845,7 @@ static int cc2520_probe(struct spi_device *spi)
 	struct cc2520_platform_data *pdata;
 	int ret;
 
-	priv = devm_kzalloc(&spi->dev,
-			    sizeof(struct cc2520_private), GFP_KERNEL);
+	priv = devm_kzalloc(&spi->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv) {
 		ret = -ENOMEM;
 		goto err_ret;
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/3 cc2520: remove 'ret' goto label

In reply to Varka Bhadram

If allocation of memory fails instead of going to ret goto label and returning from there, we can directly return -ENOMEM on failure.

---
 drivers/net/ieee802154/cc2520.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/ieee802154/cc2520.c +4 -10
index c2e725e..8344260 100644
@@ -846,10 +846,8 @@ static int cc2520_probe(struct spi_device *spi)
 	int ret;
 
 	priv = devm_kzalloc(&spi->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		ret = -ENOMEM;
-		goto err_ret;
-	}
+	if (!priv)
+		return -ENOMEM;
 
 	spi_set_drvdata(spi, priv);
 
@@ -868,10 +866,8 @@ static int cc2520_probe(struct spi_device *spi)
 
 	priv->buf = devm_kzalloc(&spi->dev,
 				 SPI_COMMAND_BUFFER, GFP_KERNEL);
-	if (!priv->buf) {
-		ret = -ENOMEM;
-		goto err_ret;
-	}
+	if (!priv->buf)
+		return -ENOMEM;
 
 	mutex_init(&priv->buffer_mutex);
 	INIT_WORK(&priv->fifop_irqwork, cc2520_fifop_irqwork);
@@ -988,8 +984,6 @@ static int cc2520_probe(struct spi_device *spi)
 err_hw_init:
 	mutex_destroy(&priv->buffer_mutex);
 	flush_work(&priv->fifop_irqwork);
-
-err_ret:
 	return ret;
 }
 
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/3 cc2520: fix zero perm_extended_addr address

In reply to Varka Bhadram

It will remove the bug of havine zero perm_extended_addr address.

---
 drivers/net/ieee802154/cc2520.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/ieee802154/cc2520.c +1 -0
index 8344260..29bf329 100644
@@ -651,6 +651,7 @@ static int cc2520_register(struct cc2520_private *priv)
 	priv->hw->parent = &priv->spi->dev;
 	priv->hw->extra_tx_headroom = 0;
 	priv->hw->vif_data_size = sizeof(*priv);
+	ieee802154_random_extended_addr(&priv->hw->phy->perm_extended_addr);
 
 	/* We do support only 2.4 Ghz */
 	priv->hw->phy->channels_supported[0] = 0x7FFF800;
Signature · 1 line
1.7.9.5
#4 lore raw
In reply to Varka Bhadram

Hi Varka,

Quoted 10 lines

This series will introduce some cleanup code and fix for having zero perm_extended_addr address.

Varka Bhadram (3):
cc2520: use devm_kzalloc(.., sizeof(*pointer), ..) pattern
cc2520: remove 'ret' goto label
cc2520: fix zero perm_extended_addr address

drivers/net/ieee802154/cc2520.c | 18 ++++++------------

1 file changed, 6 insertions(+), 12 deletions(-)

all 3 patches have been applied to bluetooth-next tree.

Regards

Marcel