drivers/hwtracing/intel_th/msu.c: In function ‘msc_buffer_win_alloc’:
drivers/hwtracing/intel_th/msu.c:783:21: warning: unused variable ‘i’ [-Wunused-variable]
int ret = -ENOMEM, i;
^
drivers/hwtracing/intel_th/msu.c: In function ‘msc_buffer_win_free’:
drivers/hwtracing/intel_th/msu.c:863:6: warning: unused variable ‘i’ [-Wunused-variable]
int i;
^
Fix this compiler warning on arm64 platform.
Cc: Alexander Shishkin <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Suggested-by: Alexander Shishkin <[email protected]>
Signed-off-by: Shaokun Zhang <[email protected]>
---
drivers/hwtracing/intel_th/msu.c | 40 +++++++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
index 81bb54fa3ce8..49e64ca760e6 100644
--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -767,6 +767,30 @@ static int __msc_buffer_win_alloc(struct msc_window *win,
return -ENOMEM;
}
+#ifdef CONFIG_X86
+static void msc_buffer_set_uc(struct msc_window *win, unsigned int nr_blocks)
+{
+ int i;
+
+ for (i = 0; i < nr_blocks; i++)
+ /* Set the page as uncached */
+ set_memory_uc((unsigned long)msc_win_block(win, i), 1);
+}
+
+static void msc_buffer_set_wb(struct msc_window *win)
+{
+ int i;
+
+ for (i = 0; i < win->nr_blocks; i++)
+ /* Reset the page to write-back */
+ set_memory_wb((unsigned long)msc_win_block(win, i), 1);
+}
+#else /* !X86 */
+static inline void msc_buffer_set_uc(struct msc_window *win,
+ unsigned int nr_blocks) {}
+static inline void msc_buffer_set_wb(struct msc_window *win) {}
+#endif /* CONFIG_X86 */
+
/**
* msc_buffer_win_alloc() - alloc a window for a multiblock mode
* @msc: MSC device
@@ -780,7 +804,7 @@ static int __msc_buffer_win_alloc(struct msc_window *win,
static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks)
{
struct msc_window *win;
- int ret = -ENOMEM, i;
+ int ret = -ENOMEM;
if (!nr_blocks)
return 0;
@@ -811,11 +835,7 @@ static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks)
if (ret < 0)
goto err_nomem;
-#ifdef CONFIG_X86
- for (i = 0; i < ret; i++)
- /* Set the page as uncached */
- set_memory_uc((unsigned long)msc_win_block(win, i), 1);
-#endif
+ msc_buffer_set_uc(win, ret);
win->nr_blocks = ret;
@@ -860,8 +880,6 @@ static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win)
*/
static void msc_buffer_win_free(struct msc *msc, struct msc_window *win)
{
- int i;
-
msc->nr_pages -= win->nr_blocks;
list_del(&win->entry);
@@ -870,11 +888,7 @@ static void msc_buffer_win_free(struct msc *msc, struct msc_window *win)
msc->base_addr = 0;
}
-#ifdef CONFIG_X86
- for (i = 0; i < win->nr_blocks; i++)
- /* Reset the page to write-back */
- set_memory_wb((unsigned long)msc_win_block(win, i), 1);
-#endif
+ msc_buffer_set_wb(win);
__msc_buffer_win_free(msc, win);
--
2.7.4
Hi Alexander,
A gentle ping.
On 2019/5/20 19:32, Shaokun Zhang wrote:
> drivers/hwtracing/intel_th/msu.c: In function ‘msc_buffer_win_alloc’:
> drivers/hwtracing/intel_th/msu.c:783:21: warning: unused variable ‘i’ [-Wunused-variable]
> int ret = -ENOMEM, i;
> ^
> drivers/hwtracing/intel_th/msu.c: In function ‘msc_buffer_win_free’:
> drivers/hwtracing/intel_th/msu.c:863:6: warning: unused variable ‘i’ [-Wunused-variable]
> int i;
> ^
> Fix this compiler warning on arm64 platform.
>
> Cc: Alexander Shishkin <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Suggested-by: Alexander Shishkin <[email protected]>
> Signed-off-by: Shaokun Zhang <[email protected]>
> ---
> drivers/hwtracing/intel_th/msu.c | 40 +++++++++++++++++++++++++++-------------
> 1 file changed, 27 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
> index 81bb54fa3ce8..49e64ca760e6 100644
> --- a/drivers/hwtracing/intel_th/msu.c
> +++ b/drivers/hwtracing/intel_th/msu.c
> @@ -767,6 +767,30 @@ static int __msc_buffer_win_alloc(struct msc_window *win,
> return -ENOMEM;
> }
>
> +#ifdef CONFIG_X86
> +static void msc_buffer_set_uc(struct msc_window *win, unsigned int nr_blocks)
> +{
> + int i;
> +
> + for (i = 0; i < nr_blocks; i++)
> + /* Set the page as uncached */
> + set_memory_uc((unsigned long)msc_win_block(win, i), 1);
> +}
> +
> +static void msc_buffer_set_wb(struct msc_window *win)
> +{
> + int i;
> +
> + for (i = 0; i < win->nr_blocks; i++)
> + /* Reset the page to write-back */
> + set_memory_wb((unsigned long)msc_win_block(win, i), 1);
> +}
> +#else /* !X86 */
> +static inline void msc_buffer_set_uc(struct msc_window *win,
> + unsigned int nr_blocks) {}
> +static inline void msc_buffer_set_wb(struct msc_window *win) {}
> +#endif /* CONFIG_X86 */
> +
> /**
> * msc_buffer_win_alloc() - alloc a window for a multiblock mode
> * @msc: MSC device
> @@ -780,7 +804,7 @@ static int __msc_buffer_win_alloc(struct msc_window *win,
> static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks)
> {
> struct msc_window *win;
> - int ret = -ENOMEM, i;
> + int ret = -ENOMEM;
>
> if (!nr_blocks)
> return 0;
> @@ -811,11 +835,7 @@ static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks)
> if (ret < 0)
> goto err_nomem;
>
> -#ifdef CONFIG_X86
> - for (i = 0; i < ret; i++)
> - /* Set the page as uncached */
> - set_memory_uc((unsigned long)msc_win_block(win, i), 1);
> -#endif
> + msc_buffer_set_uc(win, ret);
>
> win->nr_blocks = ret;
>
> @@ -860,8 +880,6 @@ static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win)
> */
> static void msc_buffer_win_free(struct msc *msc, struct msc_window *win)
> {
> - int i;
> -
> msc->nr_pages -= win->nr_blocks;
>
> list_del(&win->entry);
> @@ -870,11 +888,7 @@ static void msc_buffer_win_free(struct msc *msc, struct msc_window *win)
> msc->base_addr = 0;
> }
>
> -#ifdef CONFIG_X86
> - for (i = 0; i < win->nr_blocks; i++)
> - /* Reset the page to write-back */
> - set_memory_wb((unsigned long)msc_win_block(win, i), 1);
> -#endif
> + msc_buffer_set_wb(win);
>
> __msc_buffer_win_free(msc, win);
>
>