Skip to content

Commit 5071919

Browse files
committed
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Johan Hedberg says: ==================== pull request: bluetooth 2017-01-16 Here are a couple of important 802.15.4 driver fixes for the 4.10 kernel. Please let me know if there are any issues pulling. Thanks. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 1a717fc + 8e38b7d commit 5071919

File tree

2 files changed

+45
-18
lines changed

2 files changed

+45
-18
lines changed

drivers/net/ieee802154/at86rf230.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,9 +1715,9 @@ static int at86rf230_probe(struct spi_device *spi)
17151715
/* Reset */
17161716
if (gpio_is_valid(rstn)) {
17171717
udelay(1);
1718-
gpio_set_value(rstn, 0);
1718+
gpio_set_value_cansleep(rstn, 0);
17191719
udelay(1);
1720-
gpio_set_value(rstn, 1);
1720+
gpio_set_value_cansleep(rstn, 1);
17211721
usleep_range(120, 240);
17221722
}
17231723

drivers/net/ieee802154/atusb.c

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,26 @@ static int atusb_read_reg(struct atusb *atusb, uint8_t reg)
117117
{
118118
struct usb_device *usb_dev = atusb->usb_dev;
119119
int ret;
120+
uint8_t *buffer;
120121
uint8_t value;
121122

123+
buffer = kmalloc(1, GFP_KERNEL);
124+
if (!buffer)
125+
return -ENOMEM;
126+
122127
dev_dbg(&usb_dev->dev, "atusb: reg = 0x%x\n", reg);
123128
ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
124129
ATUSB_REG_READ, ATUSB_REQ_FROM_DEV,
125-
0, reg, &value, 1, 1000);
126-
return ret >= 0 ? value : ret;
130+
0, reg, buffer, 1, 1000);
131+
132+
if (ret >= 0) {
133+
value = buffer[0];
134+
kfree(buffer);
135+
return value;
136+
} else {
137+
kfree(buffer);
138+
return ret;
139+
}
127140
}
128141

129142
static int atusb_write_subreg(struct atusb *atusb, uint8_t reg, uint8_t mask,
@@ -549,13 +562,6 @@ static int
549562
atusb_set_frame_retries(struct ieee802154_hw *hw, s8 retries)
550563
{
551564
struct atusb *atusb = hw->priv;
552-
struct device *dev = &atusb->usb_dev->dev;
553-
554-
if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 3) {
555-
dev_info(dev, "Automatic frame retransmission is only available from "
556-
"firmware version 0.3. Please update if you want this feature.");
557-
return -EINVAL;
558-
}
559565

560566
return atusb_write_subreg(atusb, SR_MAX_FRAME_RETRIES, retries);
561567
}
@@ -608,9 +614,13 @@ static const struct ieee802154_ops atusb_ops = {
608614
static int atusb_get_and_show_revision(struct atusb *atusb)
609615
{
610616
struct usb_device *usb_dev = atusb->usb_dev;
611-
unsigned char buffer[3];
617+
unsigned char *buffer;
612618
int ret;
613619

620+
buffer = kmalloc(3, GFP_KERNEL);
621+
if (!buffer)
622+
return -ENOMEM;
623+
614624
/* Get a couple of the ATMega Firmware values */
615625
ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
616626
ATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0,
@@ -631,15 +641,20 @@ static int atusb_get_and_show_revision(struct atusb *atusb)
631641
dev_info(&usb_dev->dev, "Please update to version 0.2 or newer");
632642
}
633643

644+
kfree(buffer);
634645
return ret;
635646
}
636647

637648
static int atusb_get_and_show_build(struct atusb *atusb)
638649
{
639650
struct usb_device *usb_dev = atusb->usb_dev;
640-
char build[ATUSB_BUILD_SIZE + 1];
651+
char *build;
641652
int ret;
642653

654+
build = kmalloc(ATUSB_BUILD_SIZE + 1, GFP_KERNEL);
655+
if (!build)
656+
return -ENOMEM;
657+
643658
ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
644659
ATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0,
645660
build, ATUSB_BUILD_SIZE, 1000);
@@ -648,6 +663,7 @@ static int atusb_get_and_show_build(struct atusb *atusb)
648663
dev_info(&usb_dev->dev, "Firmware: build %s\n", build);
649664
}
650665

666+
kfree(build);
651667
return ret;
652668
}
653669

@@ -698,7 +714,7 @@ static int atusb_get_and_show_chip(struct atusb *atusb)
698714
static int atusb_set_extended_addr(struct atusb *atusb)
699715
{
700716
struct usb_device *usb_dev = atusb->usb_dev;
701-
unsigned char buffer[IEEE802154_EXTENDED_ADDR_LEN];
717+
unsigned char *buffer;
702718
__le64 extended_addr;
703719
u64 addr;
704720
int ret;
@@ -710,12 +726,20 @@ static int atusb_set_extended_addr(struct atusb *atusb)
710726
return 0;
711727
}
712728

729+
buffer = kmalloc(IEEE802154_EXTENDED_ADDR_LEN, GFP_KERNEL);
730+
if (!buffer)
731+
return -ENOMEM;
732+
713733
/* Firmware is new enough so we fetch the address from EEPROM */
714734
ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),
715735
ATUSB_EUI64_READ, ATUSB_REQ_FROM_DEV, 0, 0,
716736
buffer, IEEE802154_EXTENDED_ADDR_LEN, 1000);
717-
if (ret < 0)
718-
dev_err(&usb_dev->dev, "failed to fetch extended address\n");
737+
if (ret < 0) {
738+
dev_err(&usb_dev->dev, "failed to fetch extended address, random address set\n");
739+
ieee802154_random_extended_addr(&atusb->hw->phy->perm_extended_addr);
740+
kfree(buffer);
741+
return ret;
742+
}
719743

720744
memcpy(&extended_addr, buffer, IEEE802154_EXTENDED_ADDR_LEN);
721745
/* Check if read address is not empty and the unicast bit is set correctly */
@@ -729,6 +753,7 @@ static int atusb_set_extended_addr(struct atusb *atusb)
729753
&addr);
730754
}
731755

756+
kfree(buffer);
732757
return ret;
733758
}
734759

@@ -770,8 +795,7 @@ static int atusb_probe(struct usb_interface *interface,
770795

771796
hw->parent = &usb_dev->dev;
772797
hw->flags = IEEE802154_HW_TX_OMIT_CKSUM | IEEE802154_HW_AFILT |
773-
IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS |
774-
IEEE802154_HW_FRAME_RETRIES;
798+
IEEE802154_HW_PROMISCUOUS | IEEE802154_HW_CSMA_PARAMS;
775799

776800
hw->phy->flags = WPAN_PHY_FLAG_TXPOWER | WPAN_PHY_FLAG_CCA_ED_LEVEL |
777801
WPAN_PHY_FLAG_CCA_MODE;
@@ -800,6 +824,9 @@ static int atusb_probe(struct usb_interface *interface,
800824
atusb_get_and_show_build(atusb);
801825
atusb_set_extended_addr(atusb);
802826

827+
if (atusb->fw_ver_maj >= 0 && atusb->fw_ver_min >= 3)
828+
hw->flags |= IEEE802154_HW_FRAME_RETRIES;
829+
803830
ret = atusb_get_and_clear_error(atusb);
804831
if (ret) {
805832
dev_err(&atusb->usb_dev->dev,

0 commit comments

Comments
 (0)