root/drivers/iio/gyro/bmg160_i2c.c

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

DEFINITIONS

This source file includes following definitions.
  1. bmg160_i2c_probe
  2. bmg160_i2c_remove

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 #include <linux/i2c.h>
   3 #include <linux/regmap.h>
   4 #include <linux/iio/iio.h>
   5 #include <linux/module.h>
   6 #include <linux/acpi.h>
   7 
   8 #include "bmg160.h"
   9 
  10 static const struct regmap_config bmg160_regmap_i2c_conf = {
  11         .reg_bits = 8,
  12         .val_bits = 8,
  13         .max_register = 0x3f
  14 };
  15 
  16 static int bmg160_i2c_probe(struct i2c_client *client,
  17                             const struct i2c_device_id *id)
  18 {
  19         struct regmap *regmap;
  20         const char *name = NULL;
  21 
  22         regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
  23         if (IS_ERR(regmap)) {
  24                 dev_err(&client->dev, "Failed to register i2c regmap %d\n",
  25                         (int)PTR_ERR(regmap));
  26                 return PTR_ERR(regmap);
  27         }
  28 
  29         if (id)
  30                 name = id->name;
  31 
  32         return bmg160_core_probe(&client->dev, regmap, client->irq, name);
  33 }
  34 
  35 static int bmg160_i2c_remove(struct i2c_client *client)
  36 {
  37         bmg160_core_remove(&client->dev);
  38 
  39         return 0;
  40 }
  41 
  42 static const struct acpi_device_id bmg160_acpi_match[] = {
  43         {"BMG0160", 0},
  44         {"BMI055B", 0},
  45         {},
  46 };
  47 
  48 MODULE_DEVICE_TABLE(acpi, bmg160_acpi_match);
  49 
  50 static const struct i2c_device_id bmg160_i2c_id[] = {
  51         {"bmg160", 0},
  52         {"bmi055_gyro", 0},
  53         {}
  54 };
  55 
  56 MODULE_DEVICE_TABLE(i2c, bmg160_i2c_id);
  57 
  58 static const struct of_device_id bmg160_of_match[] = {
  59         { .compatible = "bosch,bmg160" },
  60         { .compatible = "bosch,bmi055_gyro" },
  61         { }
  62 };
  63 
  64 MODULE_DEVICE_TABLE(of, bmg160_of_match);
  65 
  66 static struct i2c_driver bmg160_i2c_driver = {
  67         .driver = {
  68                 .name   = "bmg160_i2c",
  69                 .acpi_match_table = ACPI_PTR(bmg160_acpi_match),
  70                 .of_match_table = bmg160_of_match,
  71                 .pm     = &bmg160_pm_ops,
  72         },
  73         .probe          = bmg160_i2c_probe,
  74         .remove         = bmg160_i2c_remove,
  75         .id_table       = bmg160_i2c_id,
  76 };
  77 module_i2c_driver(bmg160_i2c_driver);
  78 
  79 MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
  80 MODULE_LICENSE("GPL v2");
  81 MODULE_DESCRIPTION("BMG160 I2C Gyro driver");

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