Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754500Ab0DWV3J (ORCPT ); Fri, 23 Apr 2010 17:29:09 -0400 Received: from tex.lwn.net ([70.33.254.29]:50553 "EHLO vena.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753268Ab0DWV2g (ORCPT ); Fri, 23 Apr 2010 17:28:36 -0400 From: Jonathan Corbet To: linux-kernel@vger.kernel.org Cc: Harald Welte , Deepak Saxena , linux-fbdev@vger.kernel.org, JosephChan@via.com.tw, ScottFang@viatech.com.cn, Florian Tobias Schandinat Subject: [PATCH 04/13] viafb: package often used basic io functions Date: Fri, 23 Apr 2010 15:28:04 -0600 Message-Id: <1272058093-20914-5-git-send-email-corbet@lwn.net> X-Mailer: git-send-email 1.7.0.1 In-Reply-To: <1272058093-20914-1-git-send-email-corbet@lwn.net> References: <1272058093-20914-1-git-send-email-corbet@lwn.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5340 Lines: 166 From: Florian Tobias Schandinat This patch puts redesigned versions of the basic io functions that are used overall the driver in an extra header. It is prefixed with via_ as no framebuffer dependend stuff is in there. They were inlined as they are really simple which reduced the module size about 2.5%. The parameter order of read and write was fixed as it really doesn't make sense to change the order as they are parts of the same address and not source and destination. Wrapper which use the new functions were added to hw.h to replicate the old interface and avoid changing all old code. [jc: added one comment] Signed-off-by: Florian Tobias Schandinat --- drivers/video/via/hw.c | 22 ---------------- drivers/video/via/hw.h | 8 ++++-- drivers/video/via/via_io.h | 58 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 25 deletions(-) create mode 100644 drivers/video/via/via_io.h diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c index ecbc4f4..8a8c4dc 100644 --- a/drivers/video/via/hw.c +++ b/drivers/video/via/hw.c @@ -538,18 +538,6 @@ static void device_on(void); static void enable_second_display_channel(void); static void disable_second_display_channel(void); -void viafb_write_reg(u8 index, u16 io_port, u8 data) -{ - outb(index, io_port); - outb(data, io_port + 1); - /*DEBUG_MSG(KERN_INFO "\nIndex=%2d Value=%2d", index, data); */ -} -u8 viafb_read_reg(int io_port, u8 index) -{ - outb(index, io_port); - return inb(io_port + 1); -} - void viafb_lock_crt(void) { viafb_write_reg_mask(CR11, VIACR, BIT7, BIT7); @@ -561,16 +549,6 @@ void viafb_unlock_crt(void) viafb_write_reg_mask(CR47, VIACR, 0, BIT0); } -void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask) -{ - u8 tmp; - - outb(index, io_port); - tmp = inb(io_port + 1); - outb((data & mask) | (tmp & (~mask)), io_port + 1); - /*DEBUG_MSG(KERN_INFO "\nIndex=%2d Value=%2d", index, tmp); */ -} - void write_dac_reg(u8 index, u8 r, u8 g, u8 b) { outb(index, LUT_INDEX_WRITE); diff --git a/drivers/video/via/hw.h b/drivers/video/via/hw.h index d248f4d..23c3190 100644 --- a/drivers/video/via/hw.h +++ b/drivers/video/via/hw.h @@ -24,6 +24,11 @@ #include "viamode.h" #include "global.h" +#include "via_io.h" + +#define viafb_read_reg(p, i) via_read_reg(p, i) +#define viafb_write_reg(i, p, d) via_write_reg(p, i, d) +#define viafb_write_reg_mask(i, p, d, m) via_write_reg_mask(p, i, d, m) /*************************************************** * Definition IGA1 Design Method of CRTC Registers * @@ -870,7 +875,6 @@ extern int viafb_LCD_ON; extern int viafb_DVI_ON; extern int viafb_hotplug; -void viafb_write_reg_mask(u8 index, int io_port, u8 data, u8 mask); void viafb_set_output_path(int device, int set_iga, int output_interface); @@ -885,8 +889,6 @@ void viafb_crt_disable(void); void viafb_crt_enable(void); void init_ad9389(void); /* Access I/O Function */ -void viafb_write_reg(u8 index, u16 io_port, u8 data); -u8 viafb_read_reg(int io_port, u8 index); void viafb_lock_crt(void); void viafb_unlock_crt(void); void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga); diff --git a/drivers/video/via/via_io.h b/drivers/video/via/via_io.h new file mode 100644 index 0000000..e1c1093 --- /dev/null +++ b/drivers/video/via/via_io.h @@ -0,0 +1,58 @@ +/* + * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved. + * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. + * Copyright 2010 Florian Tobias Schandinat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; 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, write to the Free Software + * Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +/* + * basic io functions + */ + +#ifndef __VIA_IO_H__ +#define __VIA_IO_H__ + +#include +#include + +/* + * Indexed port operations. Note that these are all multi-op + * functions; every invocation will be racy if you're not holding + * reg_lock. + */ +static inline u8 via_read_reg(u16 port, u8 index) +{ + outb(index, port); + return inb(port + 1); +} + +static inline void via_write_reg(u16 port, u8 index, u8 data) +{ + outb(index, port); + outb(data, port + 1); +} + +static inline void via_write_reg_mask(u16 port, u8 index, u8 data, u8 mask) +{ + u8 old; + + outb(index, port); + old = inb(port + 1); + outb((data & mask) | (old & ~mask), port + 1); +} + +#endif /* __VIA_IO_H__ */ -- 1.7.0.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/