Module Name:    src
Committed By:   jmcneill
Date:           Tue Jun 12 23:08:37 UTC 2018

Modified Files:
        src/sys/dev/clk: clk.c

Log Message:
If setting rate on a clock with no set_rate function, and the desired rate
matches the current rate, don't return an error.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/clk/clk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/clk/clk.c
diff -u src/sys/dev/clk/clk.c:1.4 src/sys/dev/clk/clk.c:1.5
--- src/sys/dev/clk/clk.c:1.4	Sat Apr 28 15:20:33 2018
+++ src/sys/dev/clk/clk.c	Tue Jun 12 23:08:37 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: clk.c,v 1.4 2018/04/28 15:20:33 jmcneill Exp $ */
+/* $NetBSD: clk.c,v 1.5 2018/06/12 23:08:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clk.c,v 1.4 2018/04/28 15:20:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clk.c,v 1.5 2018/06/12 23:08:37 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -208,14 +208,17 @@ clk_get_rate(struct clk *clk)
 int
 clk_set_rate(struct clk *clk, u_int rate)
 {
-	if (clk->flags & CLK_SET_RATE_PARENT) {
+	if (clk->flags & CLK_SET_RATE_PARENT)
 		return clk_set_rate(clk_get_parent(clk), rate);
-	} else if (clk->domain->funcs->set_rate) {
+
+	if (clk->domain->funcs->set_rate)
 		return clk->domain->funcs->set_rate(clk->domain->priv,
 		    clk, rate);
-	} else {
-		return EINVAL;
-	}
+
+	if (clk_get_rate(clk) == rate)
+		return 0;
+
+	return EINVAL;
 }
 
 u_int

Reply via email to