Re: [PATCH] serial:Add SUNIX SDC serial port driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28.05.21 11:23, Moriis Ku wrote:

<snip>

+static struct dentry *sdc_serial_debugfs;

Dead code if CONFIG_DEBUG_FS is disabled

+static void sdc8250_do_pm(struct uart_port *p, unsigned int state,
+				unsigned int old)
+{
+	if (!state)
+		pm_runtime_get_sync(p->dev);
+
+	serial8250_do_pm(p, state, old);
+
+	if (state)
+		pm_runtime_put_sync_suspend(p->dev);
+}

Dead code if CONFIG_PM_SLEEP is disabled ?

+static int sdc8250_debugfs_add(struct sdc8250_data *data)
+{
+	struct dentry *root_dir;
+	char root_name[20];
+
+	memset(root_name, 0, sizeof(root_name));
+	sprintf(root_name, "ttyS%d", data->data.line);
+	root_dir = debugfs_create_dir(root_name, sdc_serial_debugfs);
+	if (IS_ERR(root_dir))
+		return PTR_ERR(root_dir);
+
+	debugfs_create_u32("bus_number", 0644, root_dir,
+		&data->data.bus_number);
+	debugfs_create_u32("device_number", 0644, root_dir,
+		&data->data.device_number);
+	debugfs_create_u32("irq", 0644, root_dir, &data->data.irq);
+	debugfs_create_u8("number", 0644, root_dir, &data->data.number);
+	debugfs_create_u8("version", 0644, root_dir, &data->data.version);
+	debugfs_create_u8("resource_cap", 0644, root_dir,
+		&data->data.resource_cap);
+	debugfs_create_u8("event_type", 0644, root_dir,
+		&data->data.event_type);
+	debugfs_create_u16("tx_fifo_size", 0644, root_dir,
+		&data->data.tx_fifo_size);
+	debugfs_create_u16("rx_fifo_size", 0644, root_dir,
+		&data->data.rx_fifo_size);
+	debugfs_create_u32("significand", 0644, root_dir,
+		&data->data.significand);
+	debugfs_create_u8("exponent", 0644, root_dir,
+		&data->data.exponent);
+	debugfs_create_u8("rs232_cap", 0644, root_dir, &data->data.rs232_cap);
+	debugfs_create_u8("rs422_cap", 0644, root_dir, &data->data.rs422_cap);
+	debugfs_create_u8("rs485_cap", 0644, root_dir, &data->data.rs485_cap);
+	debugfs_create_u8("ahdc_cap", 0644, root_dir, &data->data.ahdc_cap);
+	debugfs_create_u8("cs_cap", 0644, root_dir, &data->data.cs_cap);
+	debugfs_create_u8("rs422_end_cap", 0644, root_dir,
+		&data->data.rs422_end_cap);
+	debugfs_create_u8("rs485_end_cap", 0644, root_dir,
+		&data->data.rs485_end_cap);
+	debugfs_create_u32("line", 0644, root_dir, &data->data.line);
+
+	memset(data->device_name, 0, sizeof(data->device_name));
+	sprintf(data->device_name, "%s", dev_name(data->device));
+	data->device_name[strlen(data->device_name)] = 0x0a;

what exactly is this line feed for ?

+	data->debugfs_blob_device_name.data = data->device_name;
+	data->debugfs_blob_device_name.size = strlen(data->device_name) + 1;
+	debugfs_create_blob("device_name", 0644, root_dir,
+		&data->debugfs_blob_device_name);
+
+	data->debugfs = root_dir;
+	return 0;
+}

Can we make that optional (only if CONFIG_DEBUG_FS enabled) ?
Can we use devm_() functions ?

And why not using device attributes for that ?

+static void sdc8250_debugfs_remove(struct sdc8250_data *data)
+{
+	debugfs_remove_recursive(data->debugfs);
+}

See above: dead code if CONFIG_DEBUG_FS is disabled.

+static int sdc8250_read_property(struct sdc8250_data *data,
+				struct device *dev)
+{
+	int ret;
+
+	ret = device_property_read_u32(dev, "bus_number",
+				&data->data.bus_number);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u32(dev, "device_number",
+				&data->data.device_number);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u32(dev, "irq", &data->data.irq);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "number", &data->data.number);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "version", &data->data.version);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "resource_cap",
+				&data->data.resource_cap);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "event_type",
+				&data->data.event_type);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u16(dev, "tx_fifo_size",
+				&data->data.tx_fifo_size);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u16(dev, "rx_fifo_size",
+				&data->data.rx_fifo_size);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u32(dev, "significand",
+				&data->data.significand);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "exponent",
+				&data->data.exponent);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "rs232_cap", &data->data.rs232_cap);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "rs422_cap", &data->data.rs422_cap);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "rs485_cap", &data->data.rs485_cap);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "ahdc_cap", &data->data.ahdc_cap);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "cs_cap", &data->data.cs_cap);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "rs422_end_cap",
+				&data->data.rs422_end_cap);
+	if (ret < 0)
+		return -EINVAL;
+	ret = device_property_read_u8(dev, "rs485_end_cap",
+				&data->data.rs485_end_cap);
+	if (ret < 0)
+		return -EINVAL;
+
+	return 0;
+}

Is there some device tree specification for that ?

+static struct platform_driver sdc8250_platform_driver = {
+	.driver = {
+		.name = "8250_sdc",
+		.pm = &sdc8250_pm_ops,
+		.of_match_table = sdc8250_of_match,

use of_match_ptr()

+	},
+	.probe = sdc8250_probe,
+	.remove = sdc8250_remove,
+};
+
+static int __init sdc8250_init(void)
+{
+	sdc_serial_debugfs = debugfs_create_dir("sdc_serial", NULL);
+	platform_driver_register(&sdc8250_platform_driver);
+	return 0;
+}
+module_init(sdc8250_init);
+
+static void __exit sdc8250_exit(void)
+{
+	platform_driver_unregister(&sdc8250_platform_driver);
+	debugfs_remove(sdc_serial_debugfs);
+}
+module_exit(sdc8250_exit);
+
+MODULE_AUTHOR("Jason Lee <jason_lee@xxxxxxxxx>");
+MODULE_DESCRIPTION("SUNIX SDC serial port driver");
+MODULE_LICENSE("GPL");
+
+MODULE_ALIAS("platform:8250_sdc");
+
+


--
---
Hinweis: unverschlüsselte E-Mails können leicht abgehört und manipuliert
werden ! Für eine vertrauliche Kommunikation senden Sie bitte ihren
GPG/PGP-Schlüssel zu.
---
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@xxxxxxxxx -- +49-151-27565287



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux