Skip to content

Commit 871489d

Browse files
committed
Merge tag 'ieee802154-for-net-next-2023-02-20' of git://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan-next
Stefan Schmidt says: ==================== pull-request: ieee802154-next 2023-02-20 Miquel Raynal build upon his earlier work and introduced two new features into the ieee802154 stack. Beaconing to announce existing PAN's and passive scanning to discover the beacons and associated PAN's. The matching changes to the userspace configuration tool have been posted as well and will be released together with the kernel release. Arnd Bergmann and Dmitry Torokhov worked on converting the at86rf230 and cc2520 drivers away from the unused platform_data usage and towards the new gpiod API. (I had to add a revert as Dmitry found a regression on an already pushed tree on my side). Changes since v1 (pull request 2023-02-02) - Netlink API extack and NLA_POLICY* usage as suggested by Jakub - Removed always true condition found by kernel test robot - Simplify device removal with running background job for scanning - Fix problems with beacon sending in some cases by using the MLME tx path * tag 'ieee802154-for-net-next-2023-02-20' of git://git.kernel.org/pub/scm/linux/kernel/git/sschmidt/wpan-next: ieee802154: Drop device trackers mac802154: Fix an always true condition mac802154: Send beacons using the MLME Tx path ieee802154: Change error code on monitor scan netlink request ieee802154: Convert scan error messages to extack ieee802154: Use netlink policies when relevant on scan parameters ieee802154: at86rf230: switch to using gpiod API ieee802154: at86rf230: drop support for platform data Revert "at86rf230: convert to gpio descriptors" cc2520: move to gpio descriptors mac802154: Avoid superfluous endianness handling at86rf230: convert to gpio descriptors mac802154: Handle basic beaconing ieee802154: Add support for user beaconing requests mac802154: Handle passive scanning mac802154: Add MLME Tx locked helpers mac802154: Prepare forcing specific symbol duration ieee802154: Introduce a helper to validate a channel ieee802154: Define a beacon frame header ieee802154: Add support for user scanning requests ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 5f22c3b + ed9a8ad commit 871489d

File tree

23 files changed

+1368
-231
lines changed

23 files changed

+1368
-231
lines changed

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4819,7 +4819,6 @@ L: [email protected]
48194819
S: Maintained
48204820
F: Documentation/devicetree/bindings/net/ieee802154/cc2520.txt
48214821
F: drivers/net/ieee802154/cc2520.c
4822-
F: include/linux/spi/cc2520.h
48234822

48244823
CCREE ARM TRUSTZONE CRYPTOCELL REE DRIVER
48254824
M: Gilad Ben-Yossef <[email protected]>

drivers/net/ieee802154/at86rf230.c

Lines changed: 35 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include <linux/irq.h>
1818
#include <linux/gpio.h>
1919
#include <linux/delay.h>
20+
#include <linux/property.h>
2021
#include <linux/spi/spi.h>
21-
#include <linux/spi/at86rf230.h>
2222
#include <linux/regmap.h>
2323
#include <linux/skbuff.h>
2424
#include <linux/of_gpio.h>
@@ -82,7 +82,7 @@ struct at86rf230_local {
8282
struct ieee802154_hw *hw;
8383
struct at86rf2xx_chip_data *data;
8484
struct regmap *regmap;
85-
int slp_tr;
85+
struct gpio_desc *slp_tr;
8686
bool sleep;
8787

8888
struct completion state_complete;
@@ -107,8 +107,8 @@ at86rf230_async_state_change(struct at86rf230_local *lp,
107107
static inline void
108108
at86rf230_sleep(struct at86rf230_local *lp)
109109
{
110-
if (gpio_is_valid(lp->slp_tr)) {
111-
gpio_set_value(lp->slp_tr, 1);
110+
if (lp->slp_tr) {
111+
gpiod_set_value(lp->slp_tr, 1);
112112
usleep_range(lp->data->t_off_to_sleep,
113113
lp->data->t_off_to_sleep + 10);
114114
lp->sleep = true;
@@ -118,8 +118,8 @@ at86rf230_sleep(struct at86rf230_local *lp)
118118
static inline void
119119
at86rf230_awake(struct at86rf230_local *lp)
120120
{
121-
if (gpio_is_valid(lp->slp_tr)) {
122-
gpio_set_value(lp->slp_tr, 0);
121+
if (lp->slp_tr) {
122+
gpiod_set_value(lp->slp_tr, 0);
123123
usleep_range(lp->data->t_sleep_to_off,
124124
lp->data->t_sleep_to_off + 100);
125125
lp->sleep = false;
@@ -204,9 +204,9 @@ at86rf230_write_subreg(struct at86rf230_local *lp,
204204
static inline void
205205
at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp)
206206
{
207-
gpio_set_value(lp->slp_tr, 1);
207+
gpiod_set_value(lp->slp_tr, 1);
208208
udelay(1);
209-
gpio_set_value(lp->slp_tr, 0);
209+
gpiod_set_value(lp->slp_tr, 0);
210210
}
211211

212212
static bool
@@ -819,7 +819,7 @@ at86rf230_write_frame_complete(void *context)
819819

820820
ctx->trx.len = 2;
821821

822-
if (gpio_is_valid(lp->slp_tr))
822+
if (lp->slp_tr)
823823
at86rf230_slp_tr_rising_edge(lp);
824824
else
825825
at86rf230_async_write_reg(lp, RG_TRX_STATE, STATE_BUSY_TX, ctx,
@@ -1415,32 +1415,6 @@ static int at86rf230_hw_init(struct at86rf230_local *lp, u8 xtal_trim)
14151415
return at86rf230_write_subreg(lp, SR_SLOTTED_OPERATION, 0);
14161416
}
14171417

1418-
static int
1419-
at86rf230_get_pdata(struct spi_device *spi, int *rstn, int *slp_tr,
1420-
u8 *xtal_trim)
1421-
{
1422-
struct at86rf230_platform_data *pdata = spi->dev.platform_data;
1423-
int ret;
1424-
1425-
if (!IS_ENABLED(CONFIG_OF) || !spi->dev.of_node) {
1426-
if (!pdata)
1427-
return -ENOENT;
1428-
1429-
*rstn = pdata->rstn;
1430-
*slp_tr = pdata->slp_tr;
1431-
*xtal_trim = pdata->xtal_trim;
1432-
return 0;
1433-
}
1434-
1435-
*rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
1436-
*slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
1437-
ret = of_property_read_u8(spi->dev.of_node, "xtal-trim", xtal_trim);
1438-
if (ret < 0 && ret != -EINVAL)
1439-
return ret;
1440-
1441-
return 0;
1442-
}
1443-
14441418
static int
14451419
at86rf230_detect_device(struct at86rf230_local *lp)
14461420
{
@@ -1546,41 +1520,47 @@ static int at86rf230_probe(struct spi_device *spi)
15461520
{
15471521
struct ieee802154_hw *hw;
15481522
struct at86rf230_local *lp;
1523+
struct gpio_desc *slp_tr;
1524+
struct gpio_desc *rstn;
15491525
unsigned int status;
1550-
int rc, irq_type, rstn, slp_tr;
1551-
u8 xtal_trim = 0;
1526+
int rc, irq_type;
1527+
u8 xtal_trim;
15521528

15531529
if (!spi->irq) {
15541530
dev_err(&spi->dev, "no IRQ specified\n");
15551531
return -EINVAL;
15561532
}
15571533

1558-
rc = at86rf230_get_pdata(spi, &rstn, &slp_tr, &xtal_trim);
1534+
rc = device_property_read_u8(&spi->dev, "xtal-trim", &xtal_trim);
15591535
if (rc < 0) {
1560-
dev_err(&spi->dev, "failed to parse platform_data: %d\n", rc);
1561-
return rc;
1562-
}
1563-
1564-
if (gpio_is_valid(rstn)) {
1565-
rc = devm_gpio_request_one(&spi->dev, rstn,
1566-
GPIOF_OUT_INIT_HIGH, "rstn");
1567-
if (rc)
1536+
if (rc != -EINVAL) {
1537+
dev_err(&spi->dev,
1538+
"failed to parse xtal-trim: %d\n", rc);
15681539
return rc;
1540+
}
1541+
xtal_trim = 0;
15691542
}
15701543

1571-
if (gpio_is_valid(slp_tr)) {
1572-
rc = devm_gpio_request_one(&spi->dev, slp_tr,
1573-
GPIOF_OUT_INIT_LOW, "slp_tr");
1574-
if (rc)
1575-
return rc;
1576-
}
1544+
rstn = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW);
1545+
rc = PTR_ERR_OR_ZERO(rstn);
1546+
if (rc)
1547+
return rc;
1548+
1549+
gpiod_set_consumer_name(rstn, "rstn");
1550+
1551+
slp_tr = devm_gpiod_get_optional(&spi->dev, "sleep", GPIOD_OUT_LOW);
1552+
rc = PTR_ERR_OR_ZERO(slp_tr);
1553+
if (rc)
1554+
return rc;
1555+
1556+
gpiod_set_consumer_name(slp_tr, "slp_tr");
15771557

15781558
/* Reset */
1579-
if (gpio_is_valid(rstn)) {
1559+
if (rstn) {
15801560
udelay(1);
1581-
gpio_set_value_cansleep(rstn, 0);
1561+
gpiod_set_value_cansleep(rstn, 1);
15821562
udelay(1);
1583-
gpio_set_value_cansleep(rstn, 1);
1563+
gpiod_set_value_cansleep(rstn, 0);
15841564
usleep_range(120, 240);
15851565
}
15861566

0 commit comments

Comments
 (0)