History log of /linux-master/drivers/clocksource/timer-of.c
Revision Date Author Comments
# 4467b8ba 07-Mar-2022 Guillaume Ranquet <granquet@baylibre.com>

clocksource/drivers/timer-of: Check return value of of_iomap in timer_of_base_init()

of_base->base can either be iomapped using of_io_request_and_map() or
of_iomap() depending whether or not an of_base->name has been set.

Thus check of_base->base against NULL as of_iomap() does not return a
PTR_ERR() in case of error.

Fixes: 9aea417afa6b ("clocksource/drivers/timer-of: Don't request the resource by name")
Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
Link: https://lore.kernel.org/r/20220307172656.4836-1-granquet@baylibre.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>


# 4bf07f65 22-Mar-2021 Ingo Molnar <mingo@kernel.org>

timekeeping, clocksource: Fix various typos in comments

Fix ~56 single-word typos in timekeeping & clocksource code comments.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-kernel@vger.kernel.org


# 4411464d 16-Oct-2019 Geert Uytterhoeven <geert+renesas@glider.be>

clocksource/drivers/timer-of: Use unique device name instead of timer

If a hardware-specific driver does not provide a name, the timer-of core
falls back to device_node.name. Due to generic DT node naming policies,
that name is almost always "timer", and thus doesn't identify the actual
timer used.

Fix this by using device_node.full_name instead, which includes the unit
addrees.

Example impact on /proc/timer_list:

-Clock Event Device: timer
+Clock Event Device: timer@fcfec400

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20191016144747.29538-3-geert+renesas@glider.be


# ccb80012 16-Oct-2019 Geert Uytterhoeven <geert+renesas@glider.be>

clocksource/drivers/timer-of: Convert last full_name to %pOF

Commit 469869d18a886e04 ("clocksource: Convert to using %pOF instead of
full_name") converted all but the one just added before by commit
32f2fea6e77e64cd ("clocksource/drivers/timer-of: Handle
of_irq_get_byname() result correctly").

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20191016144747.29538-2-geert+renesas@glider.be


# 0f1a7b3f 02-Oct-2019 Linus Torvalds <torvalds@linux-foundation.org>

timer-of: don't use conditional expression with mixed 'void' types

Randy Dunlap reports on the sparse list that sparse warns about this
expression:

of_irq->percpu ? free_percpu_irq(of_irq->irq, clkevt) :
free_irq(of_irq->irq, clkevt);

and honestly, sparse is correct to warn. The return type of
free_percpu_irq() is 'void', while free_irq() returns a 'const void *'
that is the devname argument passed in to the request_irq().

You can't mix a void type with a non-void types in a conditional
expression according to the C standard. It so happens that gcc seems to
accept it - and the resulting type of the expression is void - but
there's really no reason for the kernel to have this kind of
non-standard expression with no real upside.

The natural way to write that expression is with an if-statement:

if (of_irq->percpu)
free_percpu_irq(of_irq->irq, clkevt);
else
free_irq(of_irq->irq, clkevt);

which is more legible anyway.

I'm not sure why that timer-of code seems to have this odd pattern. It
does the same at allocation time, but at least there the types match,
and it makes sense as an expression.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 76371977 21-Aug-2019 Jon Hunter <jonathanh@nvidia.com>

clocksource/drivers/timer-of: Do not warn on deferred probe

Deferred probe is an expected return value for clk_get() on many
platforms. The driver deals with it properly, so there's no need
to output a warning that may potentially confuse users.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>


# 9952f691 28-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms and conditions of the gnu general public license
version 2 as published by the free software foundation this program
is distributed in the hope it will be useful but without any
warranty without even the implied warranty of merchantability or
fitness for a particular purpose see the gnu general public license
for more details you should have received a copy of the gnu general
public license along with this program if not see http www gnu org
licenses

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 228 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190528171438.107155473@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9aea417a 08-Jan-2018 Daniel Lezcano <daniel.lezcano@linaro.org>

clocksource/drivers/timer-of: Don't request the resource by name

When the driver does not specify a name for the resource, don't use
of_io_request_and_map() but of_iomap(). That prevents resource name allocation
conflicts on some platforms which have the same name as the node.

Tested-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1515418139-23276-10-git-send-email-daniel.lezcano@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# 1c63c1c0 08-Jan-2018 Daniel Lezcano <daniel.lezcano@linaro.org>

clocksource/drivers/timer-of: Store the device node pointer in 'struct timer_of'

Under certain circumstances, some specific operations must be done with the
device node pointer, which forces the timer code to propagate the pointer to
the functions which need it.

In order to consolidate the function signatures in the different drivers
by using the timer-of structure, let's store it in the timer-of structure
as a handy pointer when it is needed.

Tested-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1515418139-23276-9-git-send-email-daniel.lezcano@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# cf7f46b9 08-Jan-2018 Daniel Lezcano <daniel.lezcano@linaro.org>

clocksource/drivers/timer-of: Add kernel documentation

The current code has no comments, neither any function descriptions. Fix this by
adding function descriptions in kernel doc format.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1515418139-23276-6-git-send-email-daniel.lezcano@linaro.org
[ Spelling and style fixes. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# 5bbf4ad9 08-Jan-2018 Daniel Lezcano <daniel.lezcano@linaro.org>

clocksource/drivers/timer-of: Fix function names

All the functions are not prefixed with 'timer_of_', fix the naming in order
to have the code consistent.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1515418139-23276-5-git-send-email-daniel.lezcano@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# 558de282 14-Nov-2017 Benjamin Gaignard <benjamin.gaignard@linaro.org>

clocksource/timer_of: Rename timer_of_exit to timer_of_cleanup

Change the function name to something more explicit since it is only used
in init error cases.

Add __init annotation and description about the function usage.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: mark.rutland@arm.com
Cc: devicetree@vger.kernel.org
Cc: alexandre.torgue@st.com
Cc: arnd@arndb.de
Cc: julien.thierry@arm.com
Cc: daniel.lezcano@linaro.org
Cc: linux@armlinux.org.uk
Cc: robh+dt@kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: mcoquelin.stm32@gmail.com
Cc: sudeep.holla@arm.com
Cc: ludovic.barre@st.com
Link: https://lkml.kernel.org/r/1510649563-22975-2-git-send-email-benjamin.gaignard@linaro.org


# f48729a9 23-Oct-2017 Benjamin Gaignard <benjamin.gaignard@linaro.org>

clocksource/drivers/timer-of: Add timer_of_exit function

The timer-of API does not provide a function to undo what has been done by
the timer_of_init() function.

Add a timer_of_exit() function.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>


# 469869d1 18-Jul-2017 Rob Herring <robh@kernel.org>

clocksource: Convert to using %pOF instead of full_name

Now that we have a custom printf format specifier, convert users of
full_name to use %pOF instead. This is preparation to remove storing
of the full path string for each node.

Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: linux-arm-kernel@lists.infradead.org
Acked-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Acked-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>


# 9e80dbd8 10-Jul-2017 Dan Carpenter <dan.carpenter@oracle.com>

clocksource/drivers/timer-of: Checking for IS_ERR() instead of NULL

The current code checks the return value of the of_io_request_and_map()
function as it was returning a NULL pointer in case of error.

However, it returns an error code encoded in the pointer return value, not a
NULL value. Fix this by checking the returned pointer against IS_ERR() and
return the error with PTR_ERR().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>


# 32f2fea6 17-Jul-2017 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

clocksource/drivers/timer-of: Handle of_irq_get_byname() result correctly

of_irq_get_byname() may return a negative error number as well as 0 on
failure, while timer_irq_init() only checks for 0, blithely continuing with
the call to request_[percpu_]irq() -- those functions expect *unsigned int*,
so would probably fail anyway when a large IRQ number resulting from a
conversion of a negative error number is passed to them... This, however,
is incorrect behavior -- error number is not IRQ number.

Filter out the negative error numbers, complain, and return them to the
timer_irq_init()'s callers...

Fixes: dc11bae78529 ("clocksource/drivers: Add timer-of common init routine")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: http://lkml.kernel.org/r/20170717180114.678825147@cogentembedded.com


# 22ece4e3 19-Jun-2017 Daniel Lezcano <daniel.lezcano@linaro.org>

clocksource/drivers/timer-of: Fix invalid iomap check

A typo in the code checks the return value of iomap against !NULL
and, thus, fails everytime the mapping succeed.

Fix this by inverting the condition in the check.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>


# b7dcc4ea 21-Jun-2017 Arnd Bergmann <arnd@arndb.de>

clocksource/drivers: Fix uninitialized variable use in timer_of_init

If none of the flags are set, 'ret' is uninitialized as pointed out
by gcc:

drivers/clocksource/timer-of.c: In function 'timer_of_init':
drivers/clocksource/timer-of.c:160:9: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Since calling the function without any of the flags is an error,
set the return value to -EINVAL for that case.

[ tglx: Get rid of the silly backwards goto while at it ]

Fixes: dc11bae78529 ("clocksource/drivers: Add timer-of common init routine")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: http://lkml.kernel.org/r/20170621215005.3870011-1-arnd@arndb.de


# dc11bae7 04-Jun-2017 Daniel Lezcano <daniel.lezcano@linaro.org>

clocksource/drivers: Add timer-of common init routine

The different drivers are all using the same pattern when initializing.

1. Get the base address
2. Get the irq number
3. Get the clock
4. Prepare and enable the clock
5. Get the rate
6. Request an interrupt

Instead of repeating again and again these steps in all the drivers, let's
provide a common init routine to give the opportunity to factor all of them
out.

We can expect a significant kernel size improvement when the common routine
will be used in all the drivers.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>