lkml.org 
[lkml]   [2023]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [RFC PATCH 1/9] apple-gmux: use cpu_to_be32 instead of manual reorder
    From
    Hi,

    On 2/10/23 20:09, Hans de Goede wrote:
    > Hi,
    >
    > On 2/10/23 05:48, Orlando Chamberlain wrote:
    >> Currently it manually flips the byte order, but we can instead use
    >> cpu_to_be32(val) for this.
    >>
    >> Signed-off-by: Orlando Chamberlain <orlandoch.dev@gmail.com>
    >> ---
    >> drivers/platform/x86/apple-gmux.c | 18 ++----------------
    >> 1 file changed, 2 insertions(+), 16 deletions(-)
    >>
    >> diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
    >> index 9333f82cfa8a..e8cb084cb81f 100644
    >> --- a/drivers/platform/x86/apple-gmux.c
    >> +++ b/drivers/platform/x86/apple-gmux.c
    >> @@ -94,13 +94,7 @@ static u32 gmux_pio_read32(struct apple_gmux_data *gmux_data, int port)
    >> static void gmux_pio_write32(struct apple_gmux_data *gmux_data, int port,
    >> u32 val)
    >> {
    >> - int i;
    >> - u8 tmpval;
    >> -
    >> - for (i = 0; i < 4; i++) {
    >> - tmpval = (val >> (i * 8)) & 0xff;
    >> - outb(tmpval, gmux_data->iostart + port + i);
    >> - }
    >> + outl(cpu_to_be32(val), gmux_data->iostart + port);
    >> }
    >>
    >> static int gmux_index_wait_ready(struct apple_gmux_data *gmux_data)
    >
    > The ioport / indexed-ioport accessed apple_gmux-es likely are (part of?)
    > LPC bus devices . Looking at the bus level you are now changing 4 io
    > accesses with a size of 1 byte, to 1 32 bit io-access.

    Correction to myself, re-reading the LPC specification, then
    if I'm right and this is a LPC device then all IO in/out accesses
    are always 1 byte accesses. Since the LPC bus only supports 16 / 32
    bit accesses for DMA cycles.

    So presumably the outl() would get split into 4 separate 8 bit
    (port) IO accesses.

    Regards,

    Hans





    >> @@ -177,16 +171,8 @@ static u32 gmux_index_read32(struct apple_gmux_data *gmux_data, int port)
    >> static void gmux_index_write32(struct apple_gmux_data *gmux_data, int port,
    >> u32 val)
    >> {
    >> - int i;
    >> - u8 tmpval;
    >> -
    >> mutex_lock(&gmux_data->index_lock);
    >> -
    >> - for (i = 0; i < 4; i++) {
    >> - tmpval = (val >> (i * 8)) & 0xff;
    >> - outb(tmpval, gmux_data->iostart + GMUX_PORT_VALUE + i);
    >> - }
    >> -
    >> + outl(cpu_to_be32(val), gmux_data->iostart + GMUX_PORT_VALUE);
    >> gmux_index_wait_ready(gmux_data);
    >> outb(port & 0xff, gmux_data->iostart + GMUX_PORT_WRITE);
    >> gmux_index_wait_complete(gmux_data);
    >

    \
     
     \ /
      Last update: 2023-03-27 00:18    [W:2.178 / U:0.180 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site