clk: Provide dummy clk_unregister()
Subsystems (2)
PATCH 1/2 clk: Provide dummy clk_unregister()
While there's no actual implementation behind it having the call to use in drivers makes them feel neater from a driver author point of view. An actual implementation can wait for someone who needs to use the function in a real system.
--- drivers/clk/clk.c | 12 ++++++++++++ include/linux/clk-provider.h | 1 + 2 files changed, 13 insertions(+)
drivers/clk/clk.c +12 -0
@@ -1344,6 +1344,18 @@ struct clk *clk_register(struct device *dev, const char *name, }EXPORT_SYMBOL_GPL (clk_register); +/** +* clk_unregister - unregister a currently registered clock +* @clk: clock to unregister +* +* Currently unimplemented. +*/ +int clk_unregister (struct clk *clk) +{ +return -EINVAL ; +} +EXPORT_SYMBOL_GPL (clk_unregister); +/*** clk rate change notifiers ***/ /**
include/linux/clk-provider.h +1 -0
@@ -275,6 +275,7 @@ struct clk *clk_register_mux(struct device *dev, const char *name,struct clk *clk_register (struct device *dev,const char *name,const struct clk_ops *ops,struct clk_hw *hw,const char **parent_names,u8 num_parents,unsigned long flags); +int clk_unregister (struct clk *clk);/* helper functions */ const char *__clk_get_name (struct clk *clk);
Signature · 1 line
1.7.10
PATCH 2/2 clk: wm831x: Add initial WM831x clock driver
The WM831x and WM832x series of PMICs contain a flexible clocking subsystem intended to provide always on and system core clocks. It features:
- A 32.768kHz crystal oscillator which can optionally be used to pass through an externally generated clock.
- A FLL which can be clocked from either the 32.768kHz oscillator or the CLKIN pin.
- A CLKOUT pin which can bring out either the oscillator or the FLL output.
- The 32.768kHz clock can also optionally be brought out on the GPIO pins of the device.
This driver fully supports the 32.768kHz oscillator and CLKOUT. The FLL is supported only in AUTO mode, the full flexibility of the FLL cannot currently be used.
Due to a lack of access to systems where the core SoC has been converted to use the generic clock API this driver has been compile tested only.
--- MAINTAINERS | 1 + drivers/clk/Kconfig | 7 + drivers/clk/Makefile | 1 + drivers/clk/clk-wm831x.c | 402 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 411 insertions(+) create mode 100644 drivers/clk/clk-wm831x.c
MAINTAINERS +1 -0
@@ -7459,6 +7459,7 @@ W: http://opensource.wolfsonmicro.com/content/linux-drivers-wolfson-devices S: Supported F: Documentation/hwmon/wm83?? F: arch/arm/mach-s3c64xx/mach-crag6410* +F: drivers/clk/clk-wm83*.c F: drivers/leds/leds-wm83*.c F: drivers/hwmon/wm83??-hwmon.c F: drivers/input/misc/wm831x-on.c
drivers/clk/Kconfig +7 -0
@@ -44,4 +44,11 @@ config COMMON_CLK_DEBUG clk_flags, clk_prepare_count, clk_enable_count & clk_notifier_count. +config COMMON_CLK_WM831X + tristate "Clock driver for WM831x/2x PMICs" + depends on MFD_WM831X + ---help--- + Supports the clocking subsystem of the WM831x/2x series of + PMICs from Wolfson Microlectronics. + endmenu
drivers/clk/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o obj-$(CONFIG_COMMON_CLK) += clk.o clk-fixed-rate.o clk-gate.o \ clk-mux.o clk-divider.o +obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
drivers/clk/clk-wm831x.c new file +402 -0
402 lines not on this page · raw message
Signature · 1 line
1.7.10
Re: [PATCH 2/2] clk: wm831x: Add initial WM831x clock driver
drivers/clk/clk-wm831x.c line 382
Quoted 7 lines · Mark Brown
drivers/clk/clk-wm831x.c new file +7
-0+static __devexit int wm831x_clk_remove(struct platform_device *pdev) +{ +struct wm831x_clk *clkdata =dev_get_drvdata (&pdev->dev); + +clk_unregister (clkdata->clkout_hw.clk); +clk_unregister (clkdata->fll_hw.clk); +clk_unregister (clkdata->xtal_hw.clk);
And another reason returning error codes from unregister functions is a bad idea - you've just demonstrated above why that is. You created this function which returns an error code, but you're not checking it.
drivers/clk/clk.c struct clk *clk_register(struct device *dev, const char *name, · line 1355
Quoted 9 lines · Mark Brown
drivers/clk/clk.c +9
-0+/** +* clk_unregister - unregister a currently registered clock +* @clk: clock to unregister +* +* Currently unimplemented. +*/ +int clk_unregister (struct clk *clk) +{ +return -EINVAL ;
Don't make unregister calls return values. Think about this situation for a moment:
You call an unregister function in a drivers ->remove function. The unregister function fails. However, the reason the ->remove function is being called is because the module is being removed. You can't stop the module being removed once the process has started. What do you do with this error?
To put it another way, if an unregister function fails, you're buggered.
Quoted 10 lines · Russell King - ARM Linux
Don't make unregister calls return values. Think about this situation for a moment:
You call an unregister function in a drivers ->remove function. The unregister function fails. However, the reason the ->remove function is being called is because the module is being removed. You can't stop the module being removed once the process has started. What do you do with this error?
To put it another way, if an unregister function fails, you're buggered.
I absolutely agree, I think this is a stupid pattern for us to have
(generally the return values just get ignored...) but sadly it appears
to be the pattern that we have return values but ignore them probably
because the driver model does this.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120418/a8e2a324/attachment.sig>