Merge tag 'irqchip-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/maz...
[deliverable/linux.git] / drivers / iio / magnetometer / bmc150_magn_spi.c
1 /*
2 * 3-axis magnetometer driver support following SPI Bosch-Sensortec chips:
3 * - BMC150
4 * - BMC156
5 *
6 * Copyright (c) 2016, Intel Corporation.
7 *
8 * This file is subject to the terms and conditions of version 2 of
9 * the GNU General Public License. See the file COPYING in the main
10 * directory of this archive for more details.
11 */
12 #include <linux/module.h>
13 #include <linux/mod_devicetable.h>
14 #include <linux/spi/spi.h>
15 #include <linux/acpi.h>
16 #include <linux/regmap.h>
17
18 #include "bmc150_magn.h"
19
20 static int bmc150_magn_spi_probe(struct spi_device *spi)
21 {
22 struct regmap *regmap;
23 const struct spi_device_id *id = spi_get_device_id(spi);
24
25 regmap = devm_regmap_init_spi(spi, &bmc150_magn_regmap_config);
26 if (IS_ERR(regmap)) {
27 dev_err(&spi->dev, "Failed to register spi regmap %d\n",
28 (int)PTR_ERR(regmap));
29 return PTR_ERR(regmap);
30 }
31 return bmc150_magn_probe(&spi->dev, regmap, spi->irq, id->name);
32 }
33
34 static int bmc150_magn_spi_remove(struct spi_device *spi)
35 {
36 bmc150_magn_remove(&spi->dev);
37
38 return 0;
39 }
40
41 static const struct spi_device_id bmc150_magn_spi_id[] = {
42 {"bmc150_magn", 0},
43 {"bmc156_magn", 0},
44 {}
45 };
46 MODULE_DEVICE_TABLE(spi, bmc150_magn_spi_id);
47
48 static const struct acpi_device_id bmc150_magn_acpi_match[] = {
49 {"BMC150B", 0},
50 {"BMC156B", 0},
51 {},
52 };
53 MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match);
54
55 static struct spi_driver bmc150_magn_spi_driver = {
56 .probe = bmc150_magn_spi_probe,
57 .remove = bmc150_magn_spi_remove,
58 .id_table = bmc150_magn_spi_id,
59 .driver = {
60 .acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match),
61 .name = "bmc150_magn_spi",
62 },
63 };
64 module_spi_driver(bmc150_magn_spi_driver);
65
66 MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com");
67 MODULE_DESCRIPTION("BMC150 magnetometer SPI driver");
68 MODULE_LICENSE("GPL v2");
This page took 0.068798 seconds and 5 git commands to generate.