@@ -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,
107107static inline void
108108at86rf230_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)
118118static inline void
119119at86rf230_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,
204204static inline void
205205at86rf230_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
212212static 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 ,
@@ -1520,8 +1520,10 @@ static int at86rf230_probe(struct spi_device *spi)
15201520{
15211521 struct ieee802154_hw * hw ;
15221522 struct at86rf230_local * lp ;
1523+ struct gpio_desc * slp_tr ;
1524+ struct gpio_desc * rstn ;
15231525 unsigned int status ;
1524- int rc , irq_type , rstn , slp_tr ;
1526+ int rc , irq_type ;
15251527 u8 xtal_trim ;
15261528
15271529 if (!spi -> irq ) {
@@ -1539,28 +1541,26 @@ static int at86rf230_probe(struct spi_device *spi)
15391541 xtal_trim = 0 ;
15401542 }
15411543
1542- rstn = of_get_named_gpio (spi -> dev .of_node , "reset-gpio" , 0 );
1543- if (gpio_is_valid (rstn )) {
1544- rc = devm_gpio_request_one (& spi -> dev , rstn ,
1545- GPIOF_OUT_INIT_HIGH , "rstn" );
1546- if (rc )
1547- return rc ;
1548- }
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 ;
15491548
1550- slp_tr = of_get_named_gpio (spi -> dev .of_node , "sleep-gpio" , 0 );
1551- if (gpio_is_valid (slp_tr )) {
1552- rc = devm_gpio_request_one (& spi -> dev , slp_tr ,
1553- GPIOF_OUT_INIT_LOW , "slp_tr" );
1554- if (rc )
1555- return rc ;
1556- }
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" );
15571557
15581558 /* Reset */
1559- if (gpio_is_valid ( rstn ) ) {
1559+ if (rstn ) {
15601560 udelay (1 );
1561- gpio_set_value_cansleep (rstn , 0 );
1561+ gpiod_set_value_cansleep (rstn , 1 );
15621562 udelay (1 );
1563- gpio_set_value_cansleep (rstn , 1 );
1563+ gpiod_set_value_cansleep (rstn , 0 );
15641564 usleep_range (120 , 240 );
15651565 }
15661566
0 commit comments