root/drivers/iio/gyro/fxas21002c_spi.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. fxas21002c_spi_probe
  2. fxas21002c_spi_remove

   1 // SPDX-License-Identifier: GPL-2.0
   2 /*
   3  * Driver for NXP Fxas21002c Gyroscope - SPI
   4  *
   5  * Copyright (C) 2019 Linaro Ltd.
   6  */
   7 
   8 #include <linux/err.h>
   9 #include <linux/mod_devicetable.h>
  10 #include <linux/module.h>
  11 #include <linux/regmap.h>
  12 #include <linux/spi/spi.h>
  13 
  14 #include "fxas21002c.h"
  15 
  16 static const struct regmap_config fxas21002c_regmap_spi_conf = {
  17         .reg_bits = 8,
  18         .val_bits = 8,
  19         .max_register = FXAS21002C_REG_CTRL3,
  20 };
  21 
  22 static int fxas21002c_spi_probe(struct spi_device *spi)
  23 {
  24         const struct spi_device_id *id = spi_get_device_id(spi);
  25         struct regmap *regmap;
  26 
  27         regmap = devm_regmap_init_spi(spi, &fxas21002c_regmap_spi_conf);
  28         if (IS_ERR(regmap)) {
  29                 dev_err(&spi->dev, "Failed to register spi regmap: %ld\n",
  30                         PTR_ERR(regmap));
  31                 return PTR_ERR(regmap);
  32         }
  33 
  34         return fxas21002c_core_probe(&spi->dev, regmap, spi->irq, id->name);
  35 }
  36 
  37 static int fxas21002c_spi_remove(struct spi_device *spi)
  38 {
  39         fxas21002c_core_remove(&spi->dev);
  40 
  41         return 0;
  42 }
  43 
  44 static const struct spi_device_id fxas21002c_spi_id[] = {
  45         { "fxas21002c", 0 },
  46         { }
  47 };
  48 MODULE_DEVICE_TABLE(spi, fxas21002c_spi_id);
  49 
  50 static const struct of_device_id fxas21002c_spi_of_match[] = {
  51         { .compatible = "nxp,fxas21002c", },
  52         { }
  53 };
  54 MODULE_DEVICE_TABLE(of, fxas21002c_spi_of_match);
  55 
  56 static struct spi_driver fxas21002c_spi_driver = {
  57         .driver = {
  58                 .name = "fxas21002c_spi",
  59                 .pm = &fxas21002c_pm_ops,
  60                 .of_match_table = fxas21002c_spi_of_match,
  61         },
  62         .probe          = fxas21002c_spi_probe,
  63         .remove         = fxas21002c_spi_remove,
  64         .id_table       = fxas21002c_spi_id,
  65 };
  66 module_spi_driver(fxas21002c_spi_driver);
  67 
  68 MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
  69 MODULE_LICENSE("GPL v2");
  70 MODULE_DESCRIPTION("FXAS21002C SPI Gyro driver");

/* [<][>][^][v][top][bottom][index][help] */