svn commit: r297350 - head/sys/dev/extres/clk

Jared McNeill jmcneill at FreeBSD.org
Mon Mar 28 11:51:37 UTC 2016


Author: jmcneill
Date: Mon Mar 28 11:51:35 2016
New Revision: 297350
URL: https://svnweb.freebsd.org/changeset/base/297350

Log:
  Pass clkdev_if methods through to parent device by default.
  
  Reviewed by:		mmel, adrian (mentor)
  Approved by:		adrian (mentor)
  Differential Revision:	https://reviews.freebsd.org/D5750

Modified:
  head/sys/dev/extres/clk/clkdev_if.m

Modified: head/sys/dev/extres/clk/clkdev_if.m
==============================================================================
--- head/sys/dev/extres/clk/clkdev_if.m	Mon Mar 28 11:32:20 2016	(r297349)
+++ head/sys/dev/extres/clk/clkdev_if.m	Mon Mar 28 11:51:35 2016	(r297350)
@@ -32,18 +32,66 @@ INTERFACE clkdev;
 
 CODE {
 	#include <sys/systm.h>
+	#include <sys/bus.h>
+	static int
+	clkdev_default_write_4(device_t dev, bus_addr_t addr, uint32_t val)
+	{
+		device_t pdev;
+
+		pdev = device_get_parent(dev);
+		if (pdev == NULL)
+			return (ENXIO);
+
+		return (CLKDEV_WRITE_4(pdev, addr, val));
+	}
+
+	static int
+	clkdev_default_read_4(device_t dev, bus_addr_t addr, uint32_t *val)
+	{
+		device_t pdev;
+
+		pdev = device_get_parent(dev);
+		if (pdev == NULL)
+			return (ENXIO);
+
+		return (CLKDEV_READ_4(pdev, addr, val));
+	}
+
+	static int
+	clkdev_default_modify_4(device_t dev, bus_addr_t addr,
+	    uint32_t clear_mask, uint32_t set_mask)
+	{
+		device_t pdev;
+
+		pdev = device_get_parent(dev);
+		if (pdev == NULL)
+			return (ENXIO);
+
+		return (CLKDEV_MODIFY_4(pdev, addr, clear_mask, set_mask));
+	}
+
 	static void
 	clkdev_default_device_lock(device_t dev)
 	{
+		device_t pdev;
 
-		panic("clkdev_device_lock() is not implemented");
+		pdev = device_get_parent(dev);
+		if (pdev == NULL)
+			panic("clkdev_device_lock not implemented");
+
+		CLKDEV_DEVICE_LOCK(pdev);
 	}
 
 	static void
 	clkdev_default_device_unlock(device_t dev)
 	{
+		device_t pdev;
+
+		pdev = device_get_parent(dev);
+		if (pdev == NULL)
+			panic("clkdev_device_unlock not implemented");
 
-		panic("clkdev_device_unlock() is not implemented");
+		CLKDEV_DEVICE_UNLOCK(pdev);
 	}
 }
 
@@ -54,7 +102,7 @@ METHOD int write_4 {
 	device_t	dev;
 	bus_addr_t	addr;
 	uint32_t	val;
-};
+} DEFAULT clkdev_default_write_4;
 
 #
 # Read single register
@@ -63,7 +111,7 @@ METHOD int read_4 {
 	device_t	dev;
 	bus_addr_t	addr;
 	uint32_t	*val;
-};
+} DEFAULT clkdev_default_read_4;
 
 #
 # Modify single register
@@ -73,7 +121,7 @@ METHOD int modify_4 {
 	bus_addr_t	addr;
 	uint32_t	clear_mask;
 	uint32_t	set_mask;
-};
+} DEFAULT clkdev_default_modify_4;
 
 #
 # Get exclusive access to underlying device


More information about the svn-src-all mailing list