Skip to contentSkip to conversation

Add header file,Kconfig and Makefile

PATCH In review Morris Ku 3 participants 4 messages Mar 8, 2019 – Mar 11, 2019 1 message not in the archive

lore
Share & tools
lore

Morris Ku

author
#0 lore raw

PATCH 3/4 Add header file,Kconfig and Makefile

This patch add header file, Kconfig and Makefile.

---
 char/snx/Kconfig       |   15 +
 char/snx/Makefile      |    9 +
 char/snx/driver_extd.h |  170 ++++++
 char/snx/snx_common.h  | 1157 ++++++++++++++++++++++++++++++++++++++++
 char/snx/snx_lp.h      |  126 +++++
 char/snx/snx_ppdev.h   |   43 ++
 6 files changed, 1520 insertions(+)
 create mode 100644 char/snx/Kconfig
 create mode 100644 char/snx/Makefile
 create mode 100644 char/snx/driver_extd.h
 create mode 100644 char/snx/snx_common.h
 create mode 100644 char/snx/snx_lp.h
 create mode 100644 char/snx/snx_ppdev.h
char/snx/Kconfig new file +15 -0
new file mode 100644
index 00000000..86f38352
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Character device configuration
+#
+
+config SNX
+	tristate "SUNIX Multi-IO Board Drvier"
+	Driver for SUNIX Multi-I/O Board device driver Based on
+	drivers/char/serial.c, parport_pc.c, ppdev.c and lp.c by Linus
+	Torvalds, Theodore Ts'o.
+	help
+	   Say Y here if you have a SUNIX Multi-IO card.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called snx.
char/snx/Makefile new file +9 -0
new file mode 100644
index 00000000..47348926
@@ -0,0 +1,9 @@
+#
+# drivers/char/snx/Makefile
+#
+# Makefile for the sunix multi-io device drivers.
+#
+
+obj-$(CONFIG_SNX) += snx.o
+
+snx-y := snx_main.o snx_devtable.o snx_serial.o snx_parallel.o snx_share.o snx_ieee1284.o snx_ieee1284_ops.o snx_ppdev.o snx_lp.o
char/snx/driver_extd.h new file +170 -0

170 lines not on this page · raw message

char/snx/snx_common.h new file +1156 -0

1,156 lines not on this page · raw message

char/snx/snx_lp.h new file +126 -0

126 lines not on this page · raw message

char/snx/snx_ppdev.h new file +43 -0

43 lines not on this page · raw message

--
2.17.1

#1 lore raw
Quoted 10 lines · Morris Ku

This patch add header file, Kconfig and Makefile.

---
 char/snx/Kconfig       |   15 +
 char/snx/Makefile      |    9 +
 char/snx/driver_extd.h |  170 ++++++
 char/snx/snx_common.h  | 1157 ++++++++++++++++++++++++++++++++++++++++
 char/snx/snx_lp.h      |  126 +++++
 char/snx/snx_ppdev.h   |   43 ++

why isn't that in ./drivers/tty/serial/sunix/ ?

<snip>

char/snx/Kconfig line 6

Quoted 12 lines
char/snx/Kconfig new file +6 -0
new file mode 100644
index 00000000..86f38352
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Character device configuration
+#
+
+config SNX

please use full name: SUNIX

<snip>

Quoted 21 lines
char/snx/driver_extd.h new file +15 -0
new file mode 100644
index 00000000..27f69570
@@ -0,0 +1,170 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _SNXHW_DRVR_EXTR_H_
+#define _SNXHW_DRVR_EXTR_H_
+
+#ifndef SNX_IOCTL
+#define SNX_IOCTL 0x900
+#endif
+
+#define SNX_COMM_GET_BOARD_CNT          (SNX_IOCTL + 100)
+#define SNX_COMM_GET_BOARD_INFO         (SNX_IOCTL + 101)
+
+#define SNX_GPIO_GET                    (SNX_IOCTL + 200)
+#define SNX_GPIO_SET                    (SNX_IOCTL + 201)
+#define SNX_GPIO_READ                   (SNX_IOCTL + 202)

char/snx/driver_extd.h line 25

Quoted 10 lines
char/snx/driver_extd.h new file +10 -0
+#define SNX_GPIO_WRITE                  (SNX_IOCTL + 203)
+#define SNX_GPIO_SET_DEFAULT            (SNX_IOCTL + 204)
+#define SNX_GPIO_WRITE_DEFAULT          (SNX_IOCTL + 205)
+#define SNX_GPIO_GET_INPUT_INVERT       (SNX_IOCTL + 206)
+#define SNX_GPIO_SET_INPUT_INVERT       (SNX_IOCTL + 207)
+
+#define SNX_UART_GET_TYPE               (SNX_IOCTL + 300)
+#define SNX_UART_SET_TYPE               (SNX_IOCTL + 301)
+#define SNX_UART_GET_ACS                (SNX_IOCTL + 302)
+#define SNX_UART_SET_ACS                (SNX_IOCTL + 303)

why exactly do you introduce driver-specific ioctls ? what is "ACS"

char/snx/driver_extd.h line 34

Quoted 6 lines
char/snx/driver_extd.h new file +6 -0
+#define SNX_GPIO_IN               0
+#define SNX_GPIO_OUT              1
+#define SNX_GPIO_LOW              0
+#define SNX_GPIO_HI               1
+#define SNX_GPIO_INPUT_INVERT_D   0
+#define SNX_GPIO_INPUT_INVERT_E   1

GPIO stuff belongs into the gpio subsystem. see drivers/gpio/

<snip>

char/snx/snx_common.h line 7

Quoted 13 lines
char/snx/snx_common.h new file +7 -0
new file mode 100644
index 00000000..16dd8f02
@@ -0,0 +1,1157 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#ifdef	MODVERSIONS
+#ifndef MODULE
+#define	MODULE
+#endif
+#endif

dont need that. please drop it.

<snip>

char/snx/snx_common.h line 14

Quoted 3 lines
char/snx/snx_common.h new file +3 -0
+#ifndef KERNEL_VERSION
+#define KERNEL_VERSION(ver, rel, seq)	((ver << 16) | (rel << 8) | seq)
+#endif

same here.

Quoted 26 lines
char/snx/snx_common.h new file +26 -0
+#include <linux/errno.h>
+#include <linux/signal.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial.h>
+#include <linux/serial_reg.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/wait.h>
+#include <linux/tty_driver.h>
+#include <linux/pci.h>
+#include <linux/circ_buf.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/segment.h>
+#include <asm/serial.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/workqueue.h>
+#include <linux/moduleparam.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>

char/snx/snx_common.h line 51

Quoted 10 lines
char/snx/snx_common.h new file +10 -0
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/kref.h>
+#include <linux/parport.h>
+#include <linux/ctype.h>
+#include <linux/poll.h>
+#include <linux/sched.h>
+#include <linux/serial_8250.h>
+#include <linux/cdev.h>
+#include <linux/sched/signal.h>

are these really all needed within the header ?

char/snx/snx_common.h line 53

Quoted 1 line
char/snx/snx_common.h new file +1 -0
+extern int snx_board_count;

Why that extern field ?

char/snx/snx_common.h line 57

Quoted 3 lines
char/snx/snx_common.h new file +3 -0
+#define SNX_DRIVER_VERSION	"V2.0.4.5"
+#define SNX_DRIVER_AUTHOR	"SUNIX Co., Ltd.<[email protected]>"
+#define SNX_DRIVER_DESC	"SUNIX Multi-I/O Board Driver Module"

Does it need to be in here ? (see MODULE_*() macros)

<snip>

Quoted 5 lines
char/snx/snx_common.h new file +5 -0
+typedef struct _PORT {
+	char		type;
+
+	int		bar1;
+	unsigned char	offset1;

char/snx/snx_common.h line 375

Quoted 10 lines
char/snx/snx_common.h new file +10 -0
+	unsigned char	length1;
+
+	int		bar2;
+	unsigned char	offset2;
+	unsigned char	length2;
+
+	unsigned int	intmask;
+	unsigned int	chip_flag;
+
+} PORT;

please no uppercase type names, and use proper prefix.

char/snx/snx_common.h line 486

Quoted 10 lines
char/snx/snx_common.h new file +10 -0
+#if defined(__i386__) && (defined(CONFIG_M386) ||	\
+defined(CONFIG_M486))
+#define SNX_SERIAL_INLINE
+#endif
+
+#ifdef SNX_SERIAL_INLINE
+#define _INLINE_ inline
+#else
+#define _INLINE_
+#endif

what is that for ?!

char/snx/snx_common.h line 564

Quoted 10 lines
char/snx/snx_common.h new file +10 -0
+struct snx_ser_driver {
+	struct module	*owner;
+	const char	*driver_name;
+	const char	*dev_name;
+	int		major;
+	int		minor;
+	int		nr;
+	struct snx_ser_state	*state;
+	struct tty_driver	*tty_driver;
+};

oh, not good. the struct tty_driver should be contained in snx_ser_driver (not a pointer to it). or the other way round:
give the tty driver a pointer to a driver-private struct.

and this data looks as it should be assigned to individual devices, not to driver globally.

char/snx/snx_common.h line 86

Quoted 1 line
char/snx/snx_common.h new file +1 -0
+#include <linux/tty_flip.h>

put all includes together at the top

Quoted 20 lines
char/snx/snx_common.h new file +20 -0
+static inline void snx_ser_insert_char
+(
+		struct snx_ser_port *port,
+		unsigned int status,
+		unsigned int overrun,
+		unsigned int ch,
+		unsigned int flag
+)
+{
+	struct snx_ser_info *info = port->info;
+	struct tty_struct *tty = info->tty;
+	struct snx_ser_state *state = NULL;
+	struct tty_port *tport = NULL;
+
+	state = tty->driver_data;
+
+	tport = &state->tport;
+
+	if ((status & port->ignore_status_mask & ~overrun) == 0) {
+

char/snx/snx_common.h line 683

Quoted 10 lines
char/snx/snx_common.h new file +10 -0
+		if (tty_insert_flip_char(tport, ch, flag) == 0)
+			++port->icount.buf_overrun;
+	}
+
+	if (status & ~port->ignore_status_mask & overrun) {
+
+		if (tty_insert_flip_char(tport, 0, TTY_OVERRUN) == 0)
+			++port->icount.buf_overrun;
+	}
+}

too big for an inline function.

char/snx/snx_common.h line 708

Quoted 10 lines
char/snx/snx_common.h new file +10 -0
+#define SNX_CONFIG_PARPORT_1284
+#define SNX_CONFIG_PARPORT_PC_FIFO
+
+#ifdef SNX_CONFIG_PARPORT_1284
+#undef SNX_CONFIG_PARPORT_1284
+#endif
+
+#ifdef SNX_CONFIG_PARPORT_PC_FIFO
+#undef SNX_CONFIG_PARPORT_PC_FIFO
+#endif

parport, serial port, gpio should be separate drivers.

char/snx/snx_common.h line 762

Quoted 1 line
char/snx/snx_common.h new file +1 -0
+struct snx_parport_ops {

Why does the driver introduce its own callback vectors ?

char/snx/snx_common.h line 898

Quoted 13 lines
char/snx/snx_common.h new file +13 -0
+
+struct sunix_par_port {
+	struct snx_parport	*port;
+
+	unsigned char		ctr;
+	unsigned char		ctr_writable;
+	int			ecr;
+	int			fifo_depth;
+	int			pword;
+	int			read_intr_threshold;
+	int			write_intr_threshold;
+
+	char			*dma_buf;

why not void * ?

Quoted 11 lines
char/snx/snx_common.h new file +11 -0
+	dma_addr_t		dma_handle;
+	struct list_head	list;
+
+	unsigned long		base;
+	unsigned long		base_hi;
+	int			irq;
+	int			portnum;
+	unsigned int		snx_type;
+
+	int			board_enum;
+	unsigned int		bus_number;

char/snx/snx_common.h line 919

Quoted 10 lines
char/snx/snx_common.h new file +10 -0
+	unsigned int		dev_number;
+
+	PCI_BOARD		pb_info;
+
+	unsigned char		chip_flag;
+	unsigned int		port_flag;
+};
+
+// snx_devtable.c
+extern PCI_BOARD snx_pci_board_conf[];

<snip>

why all these extern functions ?

<snip>

char/snx/snx_common.h line 1017

Quoted 3 lines
char/snx/snx_common.h new file +3 -0
+extern char snx_ser_ic_table[SNX_SER_PORT_MAX_UART][10];
+extern char snx_par_ic_table[SNX_PAR_PORT_MAX_UART][10];
+extern char snx_port_remap[2][10];

please try not to use global fields. these things look they belong into the corresponding device private data structs.

char/snx/snx_common.h line 1035

Quoted 13 lines
char/snx/snx_common.h new file +13 -0
+#define sunix_parport_write_data(p, x)	sunix_parport_pc_write_data(p, x)
+#define sunix_parport_read_data(p)	sunix_parport_pc_read_data(p)
+#define sunix_parport_write_control(p, x)	\
+sunix_parport_pc_write_control(p, x)
+#define sunix_parport_read_control(p)	sunix_parport_pc_read_control(p)
+#define sunix_parport_frob_control(p, m, v)	\
+sunix_parport_pc_frob_control(p, m, v)
+#define sunix_parport_read_status(p)	\
+sunix_parport_pc_read_status(p)
+#define sunix_parport_enable_irq(p)	sunix_parport_pc_enable_irq(p)
+#define sunix_parport_disable_irq(p)	sunix_parport_pc_disable_irq(p)
+#define sunix_parport_data_forward(p)	sunix_parport_pc_data_forward(p)
+#define sunix_parport_data_reverse(p)	sunix_parport_pc_data_reverse(p)

does that really need to be in a header file ?

<snip>

Quoted 11 lines
char/snx/snx_common.h new file +11 -0
+static inline unsigned char sunix_parport_pc_frob_control(
+struct snx_parport *p, unsigned char mask, unsigned char val)
+{
+	const unsigned char wm = (PARPORT_CONTROL_STROBE |
+							PARPORT_CONTROL_AUTOFD |
+							PARPORT_CONTROL_INIT |
+							PARPORT_CONTROL_SELECT);
+
+	if (mask & 0x20) {
+		if (val & 0x20)
+			sunix_parport_pc_data_reverse(p);

char/snx/snx_common.h line 1124

Quoted 10 lines
char/snx/snx_common.h new file +10 -0
+		else
+			sunix_parport_pc_data_forward(p);
+
+	}
+
+	mask &= wm;
+	val &= wm;
+
+	return __sunix_parport_pc_frob_control(p, mask, val);
+}

do these functions really *need* to be in the header and static inline ? (IOW: are they really needed from multiple .c files ?)

Quoted 5 lines
char/snx/snx_lp.h new file +0 -0
new file mode 100644
index 00000000..8c48deea

<snip>

char/snx/snx_lp.h line 55

Quoted 3 lines
char/snx/snx_lp.h new file +3 -0
+#define __KERNEL__	1
+
+#ifdef __KERNEL__

doesn't belong here. drop that.

char/snx/snx_lp.h line 57

Quoted 2 lines
char/snx/snx_lp.h new file +2 -0
+
+#include <linux/mutex.h>

put this at the top. if it's really needed here.

Quoted 37 lines
char/snx/snx_ppdev.h new file +31 -0
new file mode 100644
index 00000000..635f99e1
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include "snx_common.h"
+
+#define SNX_PP_IOCTL	'p'
+
+struct snx_ppdev_frob_struct {
+	unsigned char mask;
+	unsigned char val;
+};
+
+
+#define SNX_PPSETMODE		_IOW(SNX_PP_IOCTL, 0x80, int)
+#define SNX_PPRSTATUS		_IOR(SNX_PP_IOCTL, 0x81, unsigned char)
+#define SNX_PPRCONTROL		_IOR(SNX_PP_IOCTL, 0x83, unsigned char)
+#define SNX_PPWCONTROL		_IOW(SNX_PP_IOCTL, 0x84, unsigned char)
+#define SNX_PPFCONTROL		_IOW(SNX_PP_IOCTL, 0x8e,\
+struct snx_ppdev_frob_struct)
+#define SNX_PPRDATA		_IOR(SNX_PP_IOCTL, 0x85, unsigned char)
+#define SNX_PPWDATA		_IOW(SNX_PP_IOCTL, 0x86, unsigned char)
+#define SNX_PPCLAIM		_IO(SNX_PP_IOCTL, 0x8b)
+#define SNX_PPRELEASE		_IO(SNX_PP_IOCTL, 0x8c)
+#define SNX_PPYIELD		_IO(SNX_PP_IOCTL, 0x8d)
+#define SNX_PPEXCL		_IO(SNX_PP_IOCTL, 0x8f)
+#define SNX_PPDATADIR		_IOW(SNX_PP_IOCTL, 0x90, int)
+#define SNX_PPNEGOT		_IOW(SNX_PP_IOCTL, 0x91, int)
+#define SNX_PPWCTLONIRQ		_IOW(SNX_PP_IOCTL, 0x92, unsigned char)
+#define SNX_PPCLRIRQ		_IOR(SNX_PP_IOCTL, 0x93, int)
+#define SNX_PPSETPHASE		_IOW(SNX_PP_IOCTL, 0x94, int)
+#define SNX_PPGETTIME		_IOR(SNX_PP_IOCTL, 0x95, struct timeval)
+#define SNX_PPSETTIME		_IOW(SNX_PP_IOCTL, 0x96, struct timeval)
+#define SNX_PPGETMODES		_IOR(SNX_PP_IOCTL, 0x97, unsigned int)

char/snx/snx_ppdev.h line 41

Quoted 10 lines
char/snx/snx_ppdev.h new file +10 -0
+#define SNX_PPGETMODE		_IOR(SNX_PP_IOCTL, 0x98, int)
+#define SNX_PPGETPHASE		_IOR(SNX_PP_IOCTL, 0x99, int)
+#define SNX_PPGETFLAGS		_IOR(SNX_PP_IOCTL, 0x9a, int)
+#define SNX_PPSETFLAGS		_IOW(SNX_PP_IOCTL, 0x9b, int)
+
+#define SNX_PP_FASTWRITE	(1<<2)
+#define SNX_PP_FASTREAD		(1<<3)
+#define SNX_PP_W91284PIC	(1<<4)
+
+#define SNX_PP_FLAGMASK		(SNX_PP_FASTWRITE | SNX_PP_FASTREAD \

what exactly are these needed for ?

--mtx

Signature · 3 lines
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
[email protected] -- +49-151-27565287
#2 lore raw
In reply to Morris Ku
Quoted 11 lines · Morris Ku

This patch add header file, Kconfig and Makefile.

---

char/snx/Kconfig new file +0 -0
new file mode 100644
index 00000000..86f38352

char/snx/Kconfig line 7

Quoted 7 lines
char/snx/Kconfig new file +7 -0
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Character device configuration
+#
+
+config SNX
+	tristate "SUNIX Multi-IO Board Drvier"

Driver

char/snx/Kconfig line 10

Quoted 3 lines
char/snx/Kconfig new file +3 -0
+	Driver for SUNIX Multi-I/O Board device driver Based on
+	drivers/char/serial.c, parport_pc.c, ppdev.c and lp.c by Linus
+	Torvalds, Theodore Ts'o.

kconfig does not like those 3 lines above. That indicates some lack of testing.

They could be put under "help", but they really should just be deleted or moved to some source file if you think that they are needed.

char/snx/Kconfig line 12

Quoted 2 lines
char/snx/Kconfig new file +2 -0
+	help
+	   Say Y here if you have a SUNIX Multi-IO card.

Indent with tab + 2 spaces, not 3 spaces.

Quoted 3 lines
char/snx/Kconfig new file +3 -0
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called snx.
Signature · 1 line
~Randy

A message that is not in the archive (sent off-list or not yet received): HK2PR03MB45297EB467A0A7550CCBB94795480@HK2PR03MB4529.apcprd03.prod.outlook.com

#4 lore raw
Quoted 7 lines · Morris Ku 古文俊

Hi,

Quoted 4 lines

This patch add header file, Kconfig and Makefile.

---

ok , I'll delete Kconfig  in next version.

Hi,
Please just send plain text emails -- no html.

vger.kernel.org (the mailing list server) ignores emails that contain html.

thanks.

Signature · 1 line
~Randy