Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103229331
D22260.id63997.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D22260.id63997.diff
View Options
Index: sys/dev/extres/regulator/regnode_if.m
===================================================================
--- sys/dev/extres/regulator/regnode_if.m
+++ sys/dev/extres/regulator/regnode_if.m
@@ -90,6 +90,15 @@
int *uvolt;
};
+#
+# Check if a given voltage is supported by the regulator
+# Returns 0 on success or a standard errno value.
+#
+METHOD int check_voltage {
+ struct regnode *regnode;
+ int uvolt;
+};
+
#
# Stop (shutdown) regulator
# Returns 0 on success or a standard errno value.
Index: sys/dev/extres/regulator/regulator.h
===================================================================
--- sys/dev/extres/regulator/regulator.h
+++ sys/dev/extres/regulator/regulator.h
@@ -134,6 +134,7 @@
int regulator_status(regulator_t reg, int *status);
int regulator_get_voltage(regulator_t reg, int *uvolt);
int regulator_set_voltage(regulator_t reg, int min_uvolt, int max_uvolt);
+int regulator_check_voltage(regulator_t reg, int uvolt);
#ifdef FDT
int regulator_get_by_ofw_property(device_t dev, phandle_t node, char *name,
Index: sys/dev/extres/regulator/regulator.c
===================================================================
--- sys/dev/extres/regulator/regulator.c
+++ sys/dev/extres/regulator/regulator.c
@@ -72,6 +72,7 @@
static int regnode_method_set_voltage(struct regnode *regnode, int min_uvolt,
int max_uvolt, int *udelay);
static int regnode_method_get_voltage(struct regnode *regnode, int *uvolt);
+static int regnode_method_check_voltage(struct regnode *regnode, int uvolt);
static void regulator_constraint(void *dummy);
static void regulator_shutdown(void *dummy);
@@ -84,6 +85,7 @@
REGNODEMETHOD(regnode_status, regnode_method_status),
REGNODEMETHOD(regnode_set_voltage, regnode_method_set_voltage),
REGNODEMETHOD(regnode_get_voltage, regnode_method_get_voltage),
+ REGNODEMETHOD(regnode_check_voltage, regnode_method_check_voltage),
REGNODEMETHOD_END
};
@@ -278,6 +280,16 @@
(regnode->std_param.max_uvolt - regnode->std_param.min_uvolt) / 2);
}
+static int
+regnode_method_check_voltage(struct regnode *regnode, int uvolt)
+{
+
+ if ((uvolt > regnode->std_param.max_uvolt) ||
+ (uvolt < regnode->std_param.min_uvolt))
+ return (ERANGE);
+ return (0);
+}
+
/* ----------------------------------------------------------------------------
*
* Internal functions.
@@ -995,6 +1007,22 @@
return (rv);
}
+int
+regulator_check_voltage(regulator_t reg, int uvolt)
+{
+ int rv;
+ struct regnode *regnode;
+
+ regnode = reg->regnode;
+ KASSERT(regnode->ref_cnt > 0,
+ ("Attempt to access unreferenced regulator: %s\n", regnode->name));
+
+ REG_TOPO_SLOCK();
+ rv = REGNODE_CHECK_VOLTAGE(regnode, uvolt);
+ REG_TOPO_UNLOCK();
+ return (rv);
+}
+
const char *
regulator_get_name(regulator_t reg)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 10:54 AM (10 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14798645
Default Alt Text
D22260.id63997.diff (2 KB)
Attached To
Mode
D22260: regulator: Add regulator_check_voltage function
Attached
Detach File
Event Timeline
Log In to Comment