summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDaniel Starke <daniel.starke@siemens.com>2023-03-15 11:53:54 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-29 10:50:48 +0200
commitafe3154ba87e798de87ab65c72d6e3f6cd32d9d1 (patch)
treed75409e2393f815c67d50e375ce280244fbef28a /drivers
parent8629745ccc21ba1c20bbb2aead2800cf96643536 (diff)
tty: n_gsm: add ioctl for DLC config via ldisc handle
The application which initializes the n_gsm ldisc may like to set individual default parameters for each DLCI or take over of the application specific DLCI configuration completely. This is currently not possible. It is either possible to set common default parameters for all DLCIs or let the user application set its DLCI specific configuration parameters. Add support of GSMIOC_GETCONF_DLCI and GSMIOC_SETCONF_DLCI for the n_gsm ldisc handle to support DLCI specific parameter configuration upfront. Add a code example for this use case to the n_gsm documentation. Signed-off-by: Daniel Starke <daniel.starke@siemens.com> Link: https://lore.kernel.org/r/20230315105354.6234-3-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/n_gsm.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 5bbedfc36fd1..b7e1369a035c 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -3716,7 +3716,9 @@ static int gsmld_ioctl(struct tty_struct *tty, unsigned int cmd,
{
struct gsm_config c;
struct gsm_config_ext ce;
+ struct gsm_dlci_config dc;
struct gsm_mux *gsm = tty->disc_data;
+ struct gsm_dlci *dlci;
unsigned int base;
switch (cmd) {
@@ -3741,6 +3743,33 @@ static int gsmld_ioctl(struct tty_struct *tty, unsigned int cmd,
if (copy_from_user(&ce, (void __user *)arg, sizeof(ce)))
return -EFAULT;
return gsm_config_ext(gsm, &ce);
+ case GSMIOC_GETCONF_DLCI:
+ if (copy_from_user(&dc, (void __user *)arg, sizeof(dc)))
+ return -EFAULT;
+ if (dc.channel == 0 || dc.channel >= NUM_DLCI)
+ return -EINVAL;
+ dlci = gsm->dlci[dc.channel];
+ if (!dlci) {
+ dlci = gsm_dlci_alloc(gsm, dc.channel);
+ if (!dlci)
+ return -ENOMEM;
+ }
+ gsm_dlci_copy_config_values(dlci, &dc);
+ if (copy_to_user((void __user *)arg, &dc, sizeof(dc)))
+ return -EFAULT;
+ return 0;
+ case GSMIOC_SETCONF_DLCI:
+ if (copy_from_user(&dc, (void __user *)arg, sizeof(dc)))
+ return -EFAULT;
+ if (dc.channel == 0 || dc.channel >= NUM_DLCI)
+ return -EINVAL;
+ dlci = gsm->dlci[dc.channel];
+ if (!dlci) {
+ dlci = gsm_dlci_alloc(gsm, dc.channel);
+ if (!dlci)
+ return -ENOMEM;
+ }
+ return gsm_dlci_config(dlci, &dc, 0);
default:
return n_tty_ioctl_helper(tty, cmd, arg);
}