Commit f59aba2f authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman
Browse files

isdn: capi: dead code removal



The staging isdn drivers are gone, and CONFIG_BT_CMTP is now
the only user. This means a lot of the code in the subsystem
has no remaining callers and can be removed.

Change the capi user space front-end to be part of kernelcapi,
and the combined module to only be compiled if BT_CMTP is
also enabled, then remove the interfaces that have no remaining
callers.

As the notifier list and the capi_drivers list have no callers
outside of kcapi.c, the implementation gets much simpler.

Some definitions from the include/linux/*.h headers are only
needed internally and are moved to kcapi.h.

Acked-by: default avatarDavid Miller <davem@davemloft.net>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20191210210455.3475361-2-arnd@arndb.de


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f10870b0
Loading
Loading
Loading
Loading
+0 −71
Original line number Diff line number Diff line
@@ -26,13 +26,6 @@ This standard is freely available from https://www.capi.org.
2. Driver and Device Registration
=================================

CAPI drivers optionally register themselves with Kernel CAPI by calling the
Kernel CAPI function register_capi_driver() with a pointer to a struct
capi_driver. This structure must be filled with the name and revision of the
driver, and optionally a pointer to a callback function, add_card(). The
registration can be revoked by calling the function unregister_capi_driver()
with a pointer to the same struct capi_driver.

CAPI drivers must register each of the ISDN devices they control with Kernel
CAPI by calling the Kernel CAPI function attach_capi_ctr() with a pointer to a
struct capi_ctr before they can be used. This structure must be filled with
@@ -89,9 +82,6 @@ register_capi_driver():
	the name of the driver, as a zero-terminated ASCII string
``char revision[32]``
	the revision number of the driver, as a zero-terminated ASCII string
``int (*add_card)(struct capi_driver *driver, capicardparams *data)``
	a callback function pointer (may be NULL)


4.2 struct capi_ctr
-------------------
@@ -178,12 +168,6 @@ to be set by the driver before calling attach_capi_ctr():
	pointer to a callback function returning the entry for the device in
	the CAPI controller info table, /proc/capi/controller

``const struct file_operations *proc_fops``
	pointers to callback functions for the device's proc file
	system entry, /proc/capi/controllers/<n>; pointer to the device's
	capi_ctr structure is available from struct proc_dir_entry::data
	which is available from struct inode.

Note:
  Callback functions except send_message() are never called in interrupt
  context.
@@ -267,25 +251,10 @@ _cmstruct alternative representation for CAPI parameters of type 'struct'
	    _cmsg structure members.
=========== =================================================================

Functions capi_cmsg2message() and capi_message2cmsg() are provided to convert
messages between their transport encoding described in the CAPI 2.0 standard
and their _cmsg structure representation. Note that capi_cmsg2message() does
not know or check the size of its destination buffer. The caller must make
sure it is big enough to accommodate the resulting CAPI message.


5. Lower Layer Interface Functions
==================================

(declared in <linux/isdn/capilli.h>)

::

  void register_capi_driver(struct capi_driver *drvr)
  void unregister_capi_driver(struct capi_driver *drvr)

register/unregister a driver with Kernel CAPI

::

  int attach_capi_ctr(struct capi_ctr *ctrlr)
@@ -300,13 +269,6 @@ register/unregister a device (controller) with Kernel CAPI

signal controller ready/not ready

::

  void capi_ctr_suspend_output(struct capi_ctr *ctrlr)
  void capi_ctr_resume_output(struct capi_ctr *ctrlr)

signal suspend/resume

::

  void capi_ctr_handle_message(struct capi_ctr * ctrlr, u16 applid,
@@ -319,21 +281,6 @@ for forwarding to the specified application
6. Helper Functions and Macros
==============================

Library functions (from <linux/isdn/capilli.h>):

::

  void capilib_new_ncci(struct list_head *head, u16 applid,
			u32 ncci, u32 winsize)
  void capilib_free_ncci(struct list_head *head, u16 applid, u32 ncci)
  void capilib_release_appl(struct list_head *head, u16 applid)
  void capilib_release(struct list_head *head)
  void capilib_data_b3_conf(struct list_head *head, u16 applid,
			u32 ncci, u16 msgid)
  u16  capilib_data_b3_req(struct list_head *head, u16 applid,
			u32 ncci, u16 msgid)


Macros to extract/set element values from/in a CAPI message header
(from <linux/isdn/capiutil.h>):

@@ -357,24 +304,6 @@ CAPIMSG_DATALEN(m) CAPIMSG_SETDATALEN(m, len) Data Length (u16)
Library functions for working with _cmsg structures
(from <linux/isdn/capiutil.h>):

``unsigned capi_cmsg2message(_cmsg *cmsg, u8 *msg)``
	Assembles a CAPI 2.0 message from the parameters in ``*cmsg``,
	storing the result in ``*msg``.

``unsigned capi_message2cmsg(_cmsg *cmsg, u8 *msg)``
	Disassembles the CAPI 2.0 message in ``*msg``, storing the parameters
	in ``*cmsg``.

``unsigned capi_cmsg_header(_cmsg *cmsg, u16 ApplId, u8 Command, u8 Subcommand, u16 Messagenumber, u32 Controller)``
	Fills the header part and address field of the _cmsg structure ``*cmsg``
	with the given values, zeroing the remainder of the structure so only
	parameters with non-default values need to be changed before sending
	the message.

``void capi_cmsg_answer(_cmsg *cmsg)``
	Sets the low bit of the Subcommand field in ``*cmsg``, thereby
	converting ``_REQ`` to ``_CONF`` and ``_IND`` to ``_RESP``.

``char *capi_cmd2str(u8 Command, u8 Subcommand)``
	Returns the CAPI 2.0 message name corresponding to the given command
	and subcommand values, as a static ASCII string. The return value may
+1 −1
Original line number Diff line number Diff line
@@ -3,6 +3,6 @@

# Object files in subdirectories

obj-$(CONFIG_ISDN_CAPI)			+= capi/
obj-$(CONFIG_BT_CMTP)			+= capi/
obj-$(CONFIG_MISDN)			+= mISDN/
obj-$(CONFIG_ISDN)			+= hardware/
+4 −28
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only
menuconfig ISDN_CAPI
	tristate "CAPI 2.0 subsystem"
config ISDN_CAPI
	def_bool ISDN && BT
	help
	  This provides CAPI (the Common ISDN Application Programming
	  Interface) Version 2.0, a standard making it easy for programs to
@@ -15,42 +15,18 @@ menuconfig ISDN_CAPI
	  See CONFIG_BT_CMTP for the last remaining regular driver
	  in the kernel that uses the CAPI subsystem.

if ISDN_CAPI

config CAPI_TRACE
	bool "CAPI trace support"
	default y
	def_bool BT_CMTP
	help
	  If you say Y here, the kernelcapi driver can make verbose traces
	  of CAPI messages. This feature can be enabled/disabled via IOCTL for
	  every controller (default disabled).
	  This will increase the size of the kernelcapi module by 20 KB.
	  If unsure, say Y.

config ISDN_CAPI_CAPI20
	tristate "CAPI2.0 /dev/capi20 support"
	help
	  This option will provide the CAPI 2.0 interface to userspace
	  applications via /dev/capi20. Applications should use the
	  standardized libcapi20 to access this functionality.  You should say
	  Y/M here.

config ISDN_CAPI_MIDDLEWARE
	bool "CAPI2.0 Middleware support"
	depends on ISDN_CAPI_CAPI20 && TTY
	def_bool BT_CMTP && TTY
	help
	  This option will enhance the capabilities of the /dev/capi20
	  interface.  It will provide a means of moving a data connection,
	  established via the usual /dev/capi20 interface to a special tty
	  device.  If you want to use pppd with pppdcapiplugin to dial up to
	  your ISP, say Y here.

config ISDN_CAPI_CAPIDRV_VERBOSE
	bool "Verbose reason code reporting"
	depends on ISDN_CAPI_CAPIDRV
	help
	  If you say Y here, the capidrv interface will give verbose reasons
	  for disconnecting. This will increase the size of the kernel by 7 KB.
	  If unsure, say N.

endif
+3 −15
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
# Makefile for the CAPI subsystem.
# Makefile for the CAPI subsystem used by BT_CMTP

# Ordering constraints: kernelcapi.o first

# Each configuration option enables a list of files.

obj-$(CONFIG_ISDN_CAPI)			+= kernelcapi.o
obj-$(CONFIG_ISDN_CAPI_CAPI20)		+= capi.o 
obj-$(CONFIG_ISDN_CAPI_CAPIDRV)		+= capidrv.o

# Multipart objects.

kernelcapi-y				:= kcapi.o capiutil.o capilib.o
kernelcapi-$(CONFIG_PROC_FS)		+= kcapi_proc.o

ccflags-y += -I$(srctree)/$(src)/../include -I$(srctree)/$(src)/../include/uapi
obj-$(CONFIG_BT_CMTP)			+= kernelcapi.o
kernelcapi-y				:= kcapi.o capiutil.o capi.o kcapi_proc.o
+13 −1
Original line number Diff line number Diff line
@@ -39,7 +39,9 @@
#include <linux/isdn/capiutil.h>
#include <linux/isdn/capicmd.h>

MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface");
#include "kcapi.h"

MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer and /dev/capi20 interface");
MODULE_AUTHOR("Carsten Paeth");
MODULE_LICENSE("GPL");

@@ -1412,15 +1414,22 @@ static int __init capi_init(void)
{
	const char *compileinfo;
	int major_ret;
	int ret;

	ret = kcapi_init();
	if (ret)
		return ret;

	major_ret = register_chrdev(capi_major, "capi20", &capi_fops);
	if (major_ret < 0) {
		printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
		kcapi_exit();
		return major_ret;
	}
	capi_class = class_create(THIS_MODULE, "capi");
	if (IS_ERR(capi_class)) {
		unregister_chrdev(capi_major, "capi20");
		kcapi_exit();
		return PTR_ERR(capi_class);
	}

@@ -1430,6 +1439,7 @@ static int __init capi_init(void)
		device_destroy(capi_class, MKDEV(capi_major, 0));
		class_destroy(capi_class);
		unregister_chrdev(capi_major, "capi20");
		kcapi_exit();
		return -ENOMEM;
	}

@@ -1455,6 +1465,8 @@ static void __exit capi_exit(void)
	unregister_chrdev(capi_major, "capi20");

	capinc_tty_exit();

	kcapi_exit();
}

module_init(capi_init);
Loading