All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Alexander Gordeev <agordeev@redhat.com>
Cc: kvm@vger.kernel.org, "Thomas Huth" <thuth@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [PATCH 7/9] io: Introduce generic IO accessors
Date: Wed, 20 Apr 2016 16:09:05 +0200	[thread overview]
Message-ID: <20160420140905.bmtwxhqqzf4rb5o3@hawk.localdomain> (raw)
In-Reply-To: <3d2b59e696bf88defcb85877c72889d0e0019a10.1461155725.git.agordeev@redhat.com>

On Wed, Apr 20, 2016 at 03:18:53PM +0200, Alexander Gordeev wrote:
> Cc: Andrew Jones <drjones@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
> ---
>  lib/asm-generic/io.h | 42 ++++++++++++++++++++++++++++++++++++++++++
>  lib/x86/asm/io.h     | 30 ++++++++++++++++++------------
>  2 files changed, 60 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/asm-generic/io.h b/lib/asm-generic/io.h
> index 3585ac0..5c29ece 100644
> --- a/lib/asm-generic/io.h
> +++ b/lib/asm-generic/io.h
> @@ -152,6 +152,48 @@ static inline u64 __bswap64(u64 x)
>  #define writeq(b, addr) \
>  	({ wmb(); __raw_writeq(cpu_to_le64(b), addr); })
>  
> +#ifndef inb
> +static inline uint8_t inb(unsigned long port)
> +{
> +	return readb((const volatile void __iomem *)port);
> +}
> +#endif
> +
> +#ifndef inw
> +static inline uint16_t inw(unsigned long port)
> +{
> +	return readw((const volatile void __iomem *)port);
> +}
> +#endif
> +
> +#ifndef inl
> +static inline uint32_t inl(unsigned long port)
> +{
> +	return readl((const volatile void __iomem *)port);
> +}
> +#endif
> +
> +#ifndef outb
> +static inline void outb(uint8_t value, unsigned long port)
> +{
> +	writeb(value, (volatile void __iomem *)port);
> +}
> +#endif
> +
> +#ifndef outw
> +static inline void outw(uint16_t value, unsigned long port)
> +{
> +	writew(value, (volatile void __iomem *)port);
> +}
> +#endif
> +
> +#ifndef outl
> +static inline void outl(uint32_t value, unsigned long port)
> +{
> +	writel(value, (volatile void __iomem *)port);
> +}
> +#endif
> +
>  #ifndef ioremap
>  static inline void *ioremap(u64 phys_addr, size_t size __unused)
>  {
> diff --git a/lib/x86/asm/io.h b/lib/x86/asm/io.h
> index 74451d5..03f41af 100644
> --- a/lib/x86/asm/io.h
> +++ b/lib/x86/asm/io.h
> @@ -4,40 +4,46 @@
>  #include "asm/page.h"
>  #include "asm/barrier.h"
>  
> -static inline unsigned char inb(unsigned short port)
> +#define inb inb
> +static inline uint8_t inb(unsigned long port)
>  {
>      unsigned char value;
> -    asm volatile("inb %w1, %0" : "=a" (value) : "Nd" (port));
> +    asm volatile("inb %w1, %0" : "=a" (value) : "Nd" ((unsigned short)port));
>      return value;
>  }
>  
> -static inline unsigned short inw(unsigned short port)
> +#define inw inw
> +static inline uint16_t inw(unsigned long port)
>  {
>      unsigned short value;
> -    asm volatile("inw %w1, %0" : "=a" (value) : "Nd" (port));
> +    asm volatile("inw %w1, %0" : "=a" (value) : "Nd" ((unsigned short)port));
>      return value;
>  }
>  
> -static inline unsigned int inl(unsigned short port)
> +#define inl inl
> +static inline uint32_t inl(unsigned long port)
>  {
>      unsigned int value;
> -    asm volatile("inl %w1, %0" : "=a" (value) : "Nd" (port));
> +    asm volatile("inl %w1, %0" : "=a" (value) : "Nd" ((unsigned short)port));
>      return value;
>  }
>  
> -static inline void outb(unsigned char value, unsigned short port)
> +#define outb outb
> +static inline void outb(uint8_t value, unsigned long port)
>  {
> -    asm volatile("outb %b0, %w1" : : "a"(value), "Nd"(port));
> +    asm volatile("outb %b0, %w1" : : "a"(value), "Nd"((unsigned short)port));
>  }
>  
> -static inline void outw(unsigned short value, unsigned short port)
> +#define outw outw
> +static inline void outw(uint16_t value, unsigned long port)
>  {
> -    asm volatile("outw %w0, %w1" : : "a"(value), "Nd"(port));
> +    asm volatile("outw %w0, %w1" : : "a"(value), "Nd"((unsigned short)port));
>  }
>  
> -static inline void outl(unsigned int value, unsigned short port)
> +#define outl outl
> +static inline void outl(uint32_t value, unsigned long port)
>  {
> -    asm volatile("outl %0, %w1" : : "a"(value), "Nd"(port));
> +    asm volatile("outl %0, %w1" : : "a"(value), "Nd"((unsigned short)port));
>  }
>  
>  #include <asm-generic/io.h>
> -- 
> 1.8.3.1
>

I'm not sure we need this patch, and I know Radim didn't like it when
I've proposed it in the past :-)

drew 

  reply	other threads:[~2016-04-20 14:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-20 13:18 [PATCH 0/9] x86: Cleanup low-level arch code Alexander Gordeev
2016-04-20 13:18 ` [PATCH 1/9] Remove unused and unnecessary PHYS32 macro Alexander Gordeev
2016-04-20 13:54   ` Andrew Jones
2016-04-20 13:18 ` [PATCH 2/9] Move phys_addr_t type definition to lib/libcflat.h Alexander Gordeev
2016-04-20 14:02   ` Andrew Jones
2016-04-20 13:18 ` [PATCH 3/9] x86: Introduce lib/x86/asm/page.h Alexander Gordeev
2016-04-20 13:18 ` [PATCH 4/9] x86: Introduce lib/x86/asm/io.h Alexander Gordeev
2016-04-20 13:18 ` [PATCH 5/9] x86: Introduce lib/x86/asm/barrier.h Alexander Gordeev
2016-04-20 13:18 ` [PATCH 6/9] x86: Optimize virt_to_phys() and phys_to_virt() Alexander Gordeev
2016-04-20 13:18 ` [PATCH 7/9] io: Introduce generic IO accessors Alexander Gordeev
2016-04-20 14:09   ` Andrew Jones [this message]
2016-04-21  6:37     ` Alexander Gordeev
2016-04-20 13:18 ` [PATCH 8/9] io: Make ioremap() prototype conform to Linux one Alexander Gordeev
2016-04-20 14:10   ` Andrew Jones
2016-04-21  6:19     ` Alexander Gordeev
2016-04-20 13:18 ` [PATCH 9/9] io/x86: Factor out ioremap() Alexander Gordeev
2016-04-20 14:13 ` [PATCH 0/9] x86: Cleanup low-level arch code Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160420140905.bmtwxhqqzf4rb5o3@hawk.localdomain \
    --to=drjones@redhat.com \
    --cc=agordeev@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=rkrcmar@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.