x86/topology: Fix function name in documentation
[cris-mirror.git] / drivers / base / regmap / regmap-slimbus.c
blobc90bee81d954bf2d4cdcc04c73709413e4bcfa63
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2017, Linaro Ltd.
4 #include <linux/regmap.h>
5 #include <linux/slimbus.h>
6 #include <linux/module.h>
8 #include "internal.h"
10 static int regmap_slimbus_byte_reg_read(void *context, unsigned int reg,
11 unsigned int *val)
13 struct slim_device *sdev = context;
14 int v;
16 v = slim_readb(sdev, reg);
18 if (v < 0)
19 return v;
21 *val = v;
23 return 0;
26 static int regmap_slimbus_byte_reg_write(void *context, unsigned int reg,
27 unsigned int val)
29 struct slim_device *sdev = context;
31 return slim_writeb(sdev, reg, val);
34 static struct regmap_bus regmap_slimbus_bus = {
35 .reg_write = regmap_slimbus_byte_reg_write,
36 .reg_read = regmap_slimbus_byte_reg_read,
37 .reg_format_endian_default = REGMAP_ENDIAN_LITTLE,
38 .val_format_endian_default = REGMAP_ENDIAN_LITTLE,
41 static const struct regmap_bus *regmap_get_slimbus(struct slim_device *slim,
42 const struct regmap_config *config)
44 if (config->val_bits == 8 && config->reg_bits == 8)
45 return &regmap_slimbus_bus;
47 return ERR_PTR(-ENOTSUPP);
50 struct regmap *__regmap_init_slimbus(struct slim_device *slimbus,
51 const struct regmap_config *config,
52 struct lock_class_key *lock_key,
53 const char *lock_name)
55 const struct regmap_bus *bus = regmap_get_slimbus(slimbus, config);
57 if (IS_ERR(bus))
58 return ERR_CAST(bus);
60 return __regmap_init(&slimbus->dev, bus, &slimbus->dev, config,
61 lock_key, lock_name);
63 EXPORT_SYMBOL_GPL(__regmap_init_slimbus);
65 struct regmap *__devm_regmap_init_slimbus(struct slim_device *slimbus,
66 const struct regmap_config *config,
67 struct lock_class_key *lock_key,
68 const char *lock_name)
70 const struct regmap_bus *bus = regmap_get_slimbus(slimbus, config);
72 if (IS_ERR(bus))
73 return ERR_CAST(bus);
75 return __devm_regmap_init(&slimbus->dev, bus, &slimbus, config,
76 lock_key, lock_name);
78 EXPORT_SYMBOL_GPL(__devm_regmap_init_slimbus);
80 MODULE_LICENSE("GPL v2");