Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: amplifiers: ad8366: replace reset-gpio with reset controller

Remove reset_gpio from the device state struct and use the reset_control
interface instead, using a local variable, as it is not being used
anywhere else. The reset controller init is moved out from the switch case
and optionally initialized for every device variant. Although not all
devices have a reset pin the code does not need to change if it is not
wired.

Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Rodrigo Alencar and committed by
Jonathan Cameron
ee4f8c56 5fdb9c83

+7 -6
+7 -6
drivers/iio/amplifiers/ad8366.c
··· 23 23 #include <linux/module.h> 24 24 #include <linux/mutex.h> 25 25 #include <linux/regulator/consumer.h> 26 + #include <linux/reset.h> 26 27 #include <linux/spi/spi.h> 27 28 #include <linux/types.h> 28 29 ··· 45 44 struct ad8366_state { 46 45 struct spi_device *spi; 47 46 struct mutex lock; /* protect sensor state */ 48 - struct gpio_desc *reset_gpio; 49 47 unsigned char ch[2]; 50 48 enum ad8366_type type; 51 49 const struct ad8366_info *info; ··· 248 248 static int ad8366_probe(struct spi_device *spi) 249 249 { 250 250 struct device *dev = &spi->dev; 251 + struct reset_control *rstc; 251 252 struct iio_dev *indio_dev; 252 253 struct ad8366_state *st; 253 254 int ret; ··· 279 278 case ID_ADL5240: 280 279 case ID_HMC792: 281 280 case ID_HMC1119: 282 - st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH); 283 - if (IS_ERR(st->reset_gpio)) 284 - return dev_err_probe(dev, PTR_ERR(st->reset_gpio), 285 - "Failed to get reset gpio\n"); 286 - 287 281 indio_dev->channels = ada4961_channels; 288 282 indio_dev->num_channels = ARRAY_SIZE(ada4961_channels); 289 283 break; 290 284 default: 291 285 return dev_err_probe(dev, -EINVAL, "Invalid device ID\n"); 292 286 } 287 + 288 + rstc = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL); 289 + if (IS_ERR(rstc)) 290 + return dev_err_probe(dev, PTR_ERR(rstc), 291 + "Failed to get reset controller\n"); 293 292 294 293 st->info = &ad8366_infos[st->type]; 295 294 indio_dev->name = spi_get_device_id(spi)->name;