From: Sean Wang <[email protected]>
Similar to the readx_poll_timeout() macro calling ktime_* and using
ktime_t type, which is declared in <linux/ktime.h>. So, make
include/linux/regmap.h explicitly include <linux/ktime.h>, like
include/linux/iopoll.h does. Otherwise, users of the macro will see
below errors.
error: implicit declaration of function ‘ktime_add_us’
[-Werror=implicit-function-declaration]
error: implicit declaration of function ‘ktime_get’
[-Werror=implicit-function-declaration]
error: implicit declaration of function ‘ktime_compare’
[-Werror=implicit-function-declaration]
include/linux/regmap.h:128:2: error: unknown type name ‘ktime_t’
ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
Cc: Mark Brown <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
include/linux/regmap.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 5f7ad05..b6865f0 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -15,6 +15,7 @@
#include <linux/list.h>
#include <linux/rbtree.h>
+#include <linux/ktime.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/bug.h>
--
2.7.4
From: Sean Wang <[email protected]>
Reuse the common helpers regmap_read_poll_timeout provided by Linux core
instead of an open-coded handling.
v1 -> v2:
- use macro definitions MTK_POLL_DELAY_US and MTK_POLL_TIMEOUT for
arguments sleep_us and timeout_us passing in regmap_read_poll_timeout.
- remove unnecessary linux/iopoll.h being included in.
Signed-off-by: Sean Wang <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: Weiyi Lu <[email protected]>
---
drivers/soc/mediatek/mtk-infracfg.c | 46 ++++++++++---------------------------
1 file changed, 12 insertions(+), 34 deletions(-)
diff --git a/drivers/soc/mediatek/mtk-infracfg.c b/drivers/soc/mediatek/mtk-infracfg.c
index 8c310de..958861c 100644
--- a/drivers/soc/mediatek/mtk-infracfg.c
+++ b/drivers/soc/mediatek/mtk-infracfg.c
@@ -17,6 +17,9 @@
#include <linux/soc/mediatek/infracfg.h>
#include <asm/processor.h>
+#define MTK_POLL_DELAY_US 10
+#define MTK_POLL_TIMEOUT (jiffies_to_usecs(HZ))
+
#define INFRA_TOPAXI_PROTECTEN 0x0220
#define INFRA_TOPAXI_PROTECTSTA1 0x0228
#define INFRA_TOPAXI_PROTECTEN_SET 0x0260
@@ -37,7 +40,6 @@
int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
bool reg_update)
{
- unsigned long expired;
u32 val;
int ret;
@@ -47,22 +49,11 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
else
regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_SET, mask);
- expired = jiffies + HZ;
-
- while (1) {
- ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val);
- if (ret)
- return ret;
-
- if ((val & mask) == mask)
- break;
+ ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
+ val, (val & mask) == mask,
+ MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
- cpu_relax();
- if (time_after(jiffies, expired))
- return -EIO;
- }
-
- return 0;
+ return ret;
}
/**
@@ -80,30 +71,17 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask,
bool reg_update)
{
- unsigned long expired;
int ret;
+ u32 val;
if (reg_update)
regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask, 0);
else
regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_CLR, mask);
- expired = jiffies + HZ;
-
- while (1) {
- u32 val;
-
- ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val);
- if (ret)
- return ret;
-
- if (!(val & mask))
- break;
-
- cpu_relax();
- if (time_after(jiffies, expired))
- return -EIO;
- }
+ ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
+ val, !(val & mask),
+ MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
- return 0;
+ return ret;
}
--
2.7.4
On Mon, Apr 23, 2018 at 02:42:44PM +0800, [email protected] wrote:
> From: Sean Wang <[email protected]>
>
> Similar to the readx_poll_timeout() macro calling ktime_* and using
> ktime_t type, which is declared in <linux/ktime.h>. So, make
I'm missing patch 2 here - what's the story, are there any
dependencies?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 04/23/2018 12:03 PM, Mark Brown wrote:
> On Mon, Apr 23, 2018 at 02:42:44PM +0800, [email protected] wrote:
>> From: Sean Wang <[email protected]>
>>
>> Similar to the readx_poll_timeout() macro calling ktime_* and using
>> ktime_t type, which is declared in <linux/ktime.h>. So, make
>
> I'm missing patch 2 here - what's the story, are there any dependencies?
>
You can find the second patch here:
https://patchwork.kernel.org/patch/10356237/
Regards,
Matthias
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEiUuSfQSYnG8EMsBltDliWyzx00MFAlrdsS4ACgkQtDliWyzx
00PC6Q/9EqSQ24OeBB6lqD/V58ZEwRP/w6fE9viRP/T0xsa+7NAw3oT5W79ULFYT
TSjllZ3yytjRCx5UUnLlkNgEN5UPrUUxkmqJH/q2JMuMgmxn1uRWQuyuqWD78RDG
FQqchWWuOhAf8PNR9ZeHhyRrp2E2RQWzYQ4wj49ZPU/eDFP7IiE8O/wcQ9hU/zNe
O0r7lnCi7mHHkcns2biOl4WDlkuYVRAQkMYO2w632lO0EiNrKIwyULCzy1s3r21i
C/9AMi42hAqtGYtfIEPedNvGpJllyitRmZcK0DQCXQJ8z7UKlAHhvU2GRhkHdERR
bQr/cuFXdUMaiOG6yBYSLOYIsCcXqI1NOLK0j8e7IxN36Lq+3fcyp5O6uTheHBGF
N/6Kp/fmV+v1dPsWGPOOe5Zxa0yOUSiZglhtEV+YwDrOsUyANMeLkZIeKXERA1WX
FI6uPF3eJvThMy5uEmAkmfCSlVIGCqyITg6lIOKiC/dY23H4HFrUlzf3+I8Qmmuy
In4Hk61bS1jQWFU5sWMy6/ptG2TV30sf/PJtWjGYONS4DrN6vXwTE+Sdgz1793cO
jzo1KHuGjfN7efBwlFykJZ8NLU3EAyStini+uXS24W0Rv6M/wcfNpjELIEnEw9db
rNqkp/ySzkV+uJf/4Fvpt6ysQgofuJpkM6bWDfbrg8jKpYfwid0=
=mFXy
-----END PGP SIGNATURE-----
On Mon, Apr 23, 2018 at 12:11:01PM +0200, Matthias Brugger wrote:
> On 04/23/2018 12:03 PM, Mark Brown wrote:
> > On Mon, Apr 23, 2018 at 02:42:44PM +0800, [email protected] wrote:
> >> From: Sean Wang <[email protected]>
> >> Similar to the readx_poll_timeout() macro calling ktime_* and using
> >> ktime_t type, which is declared in <linux/ktime.h>. So, make
> > I'm missing patch 2 here - what's the story, are there any dependencies?
> You can find the second patch here:
> https://patchwork.kernel.org/patch/10356237/
So it looks like there is a dependency here...?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 04/23/2018 01:50 PM, Mark Brown wrote:
> On Mon, Apr 23, 2018 at 12:11:01PM +0200, Matthias Brugger wrote:
>
>> On 04/23/2018 12:03 PM, Mark Brown wrote:
>>> On Mon, Apr 23, 2018 at 02:42:44PM +0800, [email protected]
>>> wrote:
>>>> From: Sean Wang <[email protected]>
>
>>>> Similar to the readx_poll_timeout() macro calling ktime_* and using
>>>> ktime_t type, which is declared in <linux/ktime.h>. So, make
>
>>> I'm missing patch 2 here - what's the story, are there any
>>> dependencies?
>
>> You can find the second patch here:
>> https://patchwork.kernel.org/patch/10356237/
>
> So it looks like there is a dependency here...?
>
Yes, regmap_read_poll_timeout macro uses for example ktime_compare which is
defined in linux/ktime.h
That's my understanding.
Regards,
Matthias
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEiUuSfQSYnG8EMsBltDliWyzx00MFAlrd6IYACgkQtDliWyzx
00MiNQ/5ASP4bK0FTkrulj6hCQbOaDXQcYB6wmrZGeWse4PXhAaehGBjursRlE96
SjkAa/ZDXjDIhEDHNjO2QONdkDCBiUKp1/Mp8HJeeOTne5yy9V7mFrVxxLCIoqrk
nlu8I9AY608fjUMiWHtt/nNa91QCjjYUfz/S74FhO0bB4tKBvIQb3zV0HGmqM2s2
HSxPJhXhlfQIBO5rUcVPsrndfNMDMyCHdxWF7fjN8Gm9aSDIq/j0BvUlxJXm3CmP
P3AsW1Wdom86IoLJAwCo8dAaPsHos3u7kCK1IWLxDIxl0x9ruHSTKrML01e9o0M9
VlhqdM8GfoTG4cegRHiBQRVuHNbySpSw15WmuQtvPMKfHRpUThzHFiKawhpLvN5G
Q/lnNehJvLQ/L7vaiy4kkq4PkppBGutIGobRmG5WU0NwI3sGzrAGev5IBUgkMn5w
YfMyk/Yxn39aXdOZFSViA1zOYiEfjOnxkDQoxyW/TkyA5NCBG4tAn8Mz8qRH9Z5N
G8lQ2UiLzxvhe007Ce0PXofkO6TbYoup4YebyOh7RIo13L5xsmmyenQxDb0DqpXH
g1KDhz+hijenE6/ppEKBSFg8z1NMY+ZWjFWfTV6NB96WrG8Qh+EJ4gODIQCbvYY1
xEGs3TLuyPuXAz+2pFOK5FEExskrzLnlJ+Mg1wXrJfqs3OWS2EE=
=fHpR
-----END PGP SIGNATURE-----
On Mon, Apr 23, 2018 at 04:07:10PM +0200, Matthias Brugger wrote:
> On 04/23/2018 01:50 PM, Mark Brown wrote:
> > So it looks like there is a dependency here...?
> Yes, regmap_read_poll_timeout macro uses for example ktime_compare which is
> defined in linux/ktime.h
> That's my understanding.
OK, it's important to make sure that people getting a patch series know
about stuff like this as it will affect how things are reviewed and
applied.
The following changes since commit e241e3f2bf975788a1b70dff2eb5180ca395b28e:
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost (2018-04-11 18:58:27 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git tags/regmap-ktime-fix
for you to fetch changes up to f15cd6d99198e9c15229aefec639a34a6e8174c6:
regmap: include <linux/ktime.h> from include/linux/regmap.h (2018-04-24 18:11:50 +0100)
----------------------------------------------------------------
regmap: Fix missing include of ktime.h
Required for some dependencies.
----------------------------------------------------------------
Sean Wang (1):
regmap: include <linux/ktime.h> from include/linux/regmap.h
include/linux/regmap.h | 1 +
1 file changed, 1 insertion(+)
The patch
regmap: include <linux/ktime.h> from include/linux/regmap.h
has been applied to the regmap tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
From f15cd6d99198e9c15229aefec639a34a6e8174c6 Mon Sep 17 00:00:00 2001
From: Sean Wang <[email protected]>
Date: Mon, 23 Apr 2018 14:42:44 +0800
Subject: [PATCH] regmap: include <linux/ktime.h> from include/linux/regmap.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Similar to the readx_poll_timeout() macro calling ktime_* and using
ktime_t type, which is declared in <linux/ktime.h>. So, make
include/linux/regmap.h explicitly include <linux/ktime.h>, like
include/linux/iopoll.h does. Otherwise, users of the macro will see
below errors.
error: implicit declaration of function ‘ktime_add_us’
[-Werror=implicit-function-declaration]
error: implicit declaration of function ‘ktime_get’
[-Werror=implicit-function-declaration]
error: implicit declaration of function ‘ktime_compare’
[-Werror=implicit-function-declaration]
include/linux/regmap.h:128:2: error: unknown type name ‘ktime_t’
ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
include/linux/regmap.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 5f7ad0552c03..b6865f070464 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -15,6 +15,7 @@
#include <linux/list.h>
#include <linux/rbtree.h>
+#include <linux/ktime.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/bug.h>
--
2.17.0
On 04/23/2018 08:42 AM, [email protected] wrote:
> From: Sean Wang <[email protected]>
>
> Reuse the common helpers regmap_read_poll_timeout provided by Linux core
> instead of an open-coded handling.
>
> v1 -> v2:
> - use macro definitions MTK_POLL_DELAY_US and MTK_POLL_TIMEOUT for
> arguments sleep_us and timeout_us passing in regmap_read_poll_timeout.
> - remove unnecessary linux/iopoll.h being included in.
>
> Signed-off-by: Sean Wang <[email protected]>
> Cc: Matthias Brugger <[email protected]>
> Cc: Ulf Hansson <[email protected]>
> Cc: Weiyi Lu <[email protected]>
> ---
> drivers/soc/mediatek/mtk-infracfg.c | 46 ++++++++++---------------------------
> 1 file changed, 12 insertions(+), 34 deletions(-)
>
pushed to v4.17-next/soc
> diff --git a/drivers/soc/mediatek/mtk-infracfg.c b/drivers/soc/mediatek/mtk-infracfg.c
> index 8c310de..958861c 100644
> --- a/drivers/soc/mediatek/mtk-infracfg.c
> +++ b/drivers/soc/mediatek/mtk-infracfg.c
> @@ -17,6 +17,9 @@
> #include <linux/soc/mediatek/infracfg.h>
> #include <asm/processor.h>
>
> +#define MTK_POLL_DELAY_US 10
> +#define MTK_POLL_TIMEOUT (jiffies_to_usecs(HZ))
> +
> #define INFRA_TOPAXI_PROTECTEN 0x0220
> #define INFRA_TOPAXI_PROTECTSTA1 0x0228
> #define INFRA_TOPAXI_PROTECTEN_SET 0x0260
> @@ -37,7 +40,6 @@
> int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
> bool reg_update)
> {
> - unsigned long expired;
> u32 val;
> int ret;
>
> @@ -47,22 +49,11 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
> else
> regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_SET, mask);
>
> - expired = jiffies + HZ;
> -
> - while (1) {
> - ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val);
> - if (ret)
> - return ret;
> -
> - if ((val & mask) == mask)
> - break;
> + ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
> + val, (val & mask) == mask,
> + MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
>
> - cpu_relax();
> - if (time_after(jiffies, expired))
> - return -EIO;
> - }
> -
> - return 0;
> + return ret;
> }
>
> /**
> @@ -80,30 +71,17 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
> int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask,
> bool reg_update)
> {
> - unsigned long expired;
> int ret;
> + u32 val;
>
> if (reg_update)
> regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask, 0);
> else
> regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_CLR, mask);
>
> - expired = jiffies + HZ;
> -
> - while (1) {
> - u32 val;
> -
> - ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val);
> - if (ret)
> - return ret;
> -
> - if (!(val & mask))
> - break;
> -
> - cpu_relax();
> - if (time_after(jiffies, expired))
> - return -EIO;
> - }
> + ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
> + val, !(val & mask),
> + MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
>
> - return 0;
> + return ret;
> }
>
Hi Sean,
On 04/23/2018 08:42 AM, [email protected] wrote:
> From: Sean Wang <[email protected]>
>
> Reuse the common helpers regmap_read_poll_timeout provided by Linux core
> instead of an open-coded handling.
>
> v1 -> v2:
> - use macro definitions MTK_POLL_DELAY_US and MTK_POLL_TIMEOUT for
> arguments sleep_us and timeout_us passing in regmap_read_poll_timeout.
> - remove unnecessary linux/iopoll.h being included in.
>
I just realized that you wrote the changelog here, which will make it show up in
the commit log. Thant's not what we want... (see below)
> Signed-off-by: Sean Wang <[email protected]>
> Cc: Matthias Brugger <[email protected]>
> Cc: Ulf Hansson <[email protected]>
> Cc: Weiyi Lu <[email protected]>
> ---
> drivers/soc/mediatek/mtk-infracfg.c | 46 ++++++++++---------------------------
> 1 file changed, 12 insertions(+), 34 deletions(-)
>
Please write your changelog here in the future.
I'll fix that up in my tree now, but please remember the next time :)
Thanks
Matthias