Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/include/linux/regulator Copy regulator...



details:   https://anonhg.NetBSD.org/src/rev/0c787e6dd214
branches:  trunk
changeset: 366006:0c787e6dd214
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 07:33:18 2018 +0000

description:
Copy regulator API from fdtbus.

diffstat:

 sys/external/bsd/drm2/include/linux/regulator/consumer.h |  59 +++++++++++++++-
 1 files changed, 58 insertions(+), 1 deletions(-)

diffs (71 lines):

diff -r f7941ee000c6 -r 0c787e6dd214 sys/external/bsd/drm2/include/linux/regulator/consumer.h
--- a/sys/external/bsd/drm2/include/linux/regulator/consumer.h  Mon Aug 27 07:33:09 2018 +0000
+++ b/sys/external/bsd/drm2/include/linux/regulator/consumer.h  Mon Aug 27 07:33:18 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: consumer.h,v 1.1 2018/08/27 06:35:44 riastradh Exp $   */
+/*     $NetBSD: consumer.h,v 1.2 2018/08/27 07:33:18 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,4 +32,61 @@
 #ifndef        _LINUX_REGULATOR_CONSUMER_H_
 #define        _LINUX_REGULATOR_CONSUMER_H_
 
+#include "opt_fdt.h"
+
+#ifdef FDT
+
+struct regulator {
+       struct fdtbus_regulator regulator;
+};
+
+static inline int
+regulator_get_voltage(struct regulator *reg)
+{
+       unsigned uvolt;
+       int error;
+
+       error = fdtbus_regulator_get_voltage(&reg->regulator, &uvolt);
+       if (error) {
+               /* XXX errno NetBSD->Linux */
+               KASSERTMSG(error > 0, "negative error: %d", error);
+               return -error;
+       }
+
+       KASSERTMSG(uvolt <= INT_MAX, "high voltage: %u uV", uvolt);
+       return (int)uvol;
+}
+
+static inline int
+regulator_set_voltage(struct regulator *reg, int min_uvolt, int max_uvolt)
+{
+       unsigned v;
+
+       if (min_uvolt < 0 || max_uvolt < 0)
+               return -EINVAL;
+
+       /* XXX errno NetBSD->Linux */
+       return -fdtbus_regulator_set_voltage(&reg->regulator, min_uvolt,
+           max_uvolt);
+}
+
+#else
+
+struct regulator;
+
+static inline int
+regulator_get_voltage(struct regulator *reg)
+{
+       panic("no voltage regulators here");
+}
+
+static inline int
+regulator_set_voltage(struct regulator *reg, int min_uvolt, int max_uvolt)
+{
+       panic("no voltage regulators here");
+}
+
+
+#endif
+
 #endif /* _LINUX_REGULATOR_CONSUMER_H_ */



Home | Main Index | Thread Index | Old Index