From: Tomas Hlavacek <tmshlvck@gmail.com>
To: linux-serial@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Cox <alan@linux.intel.com>
Subject: RFC: exposing uartclk value to sysfs
Date: Sat, 11 Aug 2012 00:28:43 +0200 [thread overview]
Message-ID: <CAEB7QLAJXkK6NDPVDi36n_U_X_DGh5niHJhH6FpqBUZFmXQ2Xg@mail.gmail.com> (raw)
Hello!
I have encountered quite a lot PCI cards with many different
oscillator speeds while having no differences in PCI IDs (i.e. vendor
and subsystem IDs were chip-dafault). Namely I own several no-name
cards with OX16PCI954 and various speeds. These cards need different
baud_base (= uartclk*16) settings but it can not be
autodetected/pre-set because there is no way to distinguish them.
Although there is a way to set baud_base via setserial(8) I was
wandering whether it would be possible to expose uartclk in sysfs for
read/write. I have created a following proof-of-concept experimental
patch:
From 12c7e940c978da6cca9a6d51f499e7c5b53ec4b1 Mon Sep 17 00:00:00 2001
From: Tomas Hlavacek <tmshlvck@gmail.com>
Date: Fri, 10 Aug 2012 23:43:17 +0200
Subject: [PATCH 1/1] [RFC] [experimental]: uartclk exposed to sysfs.
TODO:
* Get opinions on the whole idea of exposing uartclk to sysfs.
* Get opinions on getting struct uart_port pointer in
the get_attr_uart routine by changing driver data of the tty device.
* Correct removal of the file (problem: How to get the device
handle?)
* Synchronization.
* Add write routine.
Signed-off-by: Tomas Hlavacek <tmshlvck@gmail.com>
---
drivers/tty/serial/serial_core.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index a21dc8e..2cb6ed5 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2293,6 +2293,17 @@ struct tty_driver *uart_console_device(struct
console *co, int *index)
return p->tty_driver;
}
+static ssize_t get_attr_uartclk(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct uart_port *port = (struct uart_port *)(dev_get_drvdata(dev));
+ return snprintf(buf, PAGE_SIZE, "%d\n", port->uartclk);
+}
+
+static DEVICE_ATTR(uartclk, S_IRUGO, get_attr_uartclk, NULL);
+
/**
* uart_add_one_port - attach a driver-defined port structure
* @drv: pointer to the uart low level driver structure for this port
@@ -2354,6 +2365,12 @@ int uart_add_one_port(struct uart_driver *drv,
struct uart_port *uport)
uport->line);
}
+ dev_set_drvdata(tty_dev, uport);
+ int sret = device_create_file(tty_dev, &dev_attr_uartclk);
+ if (sret < 0)
+ dev_err(tty_dev, "failed to add uartclk attr.\n");
+
/*
* Ensure UPF_DEAD is not set.
*/
--
1.7.10.4
Tomas
--
Tomáš Hlaváček <tmshlvck@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2012-08-10 22:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 22:28 Tomas Hlavacek [this message]
2012-08-10 22:48 ` RFC: exposing uartclk value to sysfs Alan Cox
2012-08-11 8:18 ` Tomas Hlavacek
2012-08-14 7:35 ` [PATCH 1/1] [RFC] uartclk from serial_core exposed " Tomas Hlavacek
2012-08-14 12:50 ` Marek Vasut
2012-08-15 17:09 ` Tomas Hlavacek
2012-08-15 17:12 ` [PATCHv2 " Tomas Hlavacek
2012-08-16 10:31 ` [PATCH " Alan Cox
2012-08-17 14:43 ` [PATCHv3 " Tomas Hlavacek
2012-08-17 15:06 ` Greg KH
2012-08-17 16:30 ` Tomas Hlavacek
2012-08-17 16:54 ` Greg KH
2012-08-17 18:44 ` Marek Vasut
2012-08-17 19:01 ` Greg KH
2012-08-17 20:25 ` Tomas Hlavacek
2012-08-17 15:07 ` Alan Cox
2012-08-19 18:34 ` [PATCHv4 " Tomas Hlavacek
2012-08-21 13:24 ` Tomas Hlavacek
2012-08-21 13:44 ` Alan Cox
2012-09-05 20:36 ` Greg KH
2012-09-05 23:16 ` [PATCHv5 1/1] uartclk value " Tomas Hlavacek
2012-09-05 23:42 ` Greg KH
2012-09-06 1:01 ` Tomas Hlavacek
2012-09-06 1:17 ` [PATCH v6] " Tomas Hlavacek
2012-09-06 16:23 ` [PATCH v6] tty: " Greg KH
2012-09-06 17:54 ` [PATCH v6] " Jiri Slaby
2012-09-06 18:39 ` Tomas Hlavacek
2012-09-06 18:54 ` Jiri Slaby
2012-09-06 19:41 ` Tomas Hlavacek
2012-09-06 19:47 ` Jiri Slaby
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAEB7QLAJXkK6NDPVDi36n_U_X_DGh5niHJhH6FpqBUZFmXQ2Xg@mail.gmail.com \
--to=tmshlvck@gmail.com \
--cc=alan@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).