aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parport
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-11-03 14:51:08 -1000
committerLinus Torvalds <torvalds@linux-foundation.org>2023-11-03 14:51:08 -1000
commitd99b91a99be430be45413052bb428107c435918b (patch)
tree61f44b60b9423760c1b078421d1ebabcb6cf7ae2 /drivers/parport
parente392ea4d4d00880bf94550151b1ace4f88a4b17a (diff)
parentfa10f413091a43f801f82b3cf484f15d6fc9266f (diff)
downloadlinux-d99b91a99be430be45413052bb428107c435918b.tar.gz
Merge tag 'char-misc-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc updates from Greg KH: "Here is the big set of char/misc and other small driver subsystem changes for 6.7-rc1. Included in here are: - IIO subsystem driver updates and additions (largest part of this pull request) - FPGA subsystem driver updates - Counter subsystem driver updates - ICC subsystem driver updates - extcon subsystem driver updates - mei driver updates and additions - nvmem subsystem driver updates and additions - comedi subsystem dependency fixes - parport driver fixups - cdx subsystem driver and core updates - splice support for /dev/zero and /dev/full - other smaller driver cleanups All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (326 commits) cdx: add sysfs for subsystem, class and revision cdx: add sysfs for bus reset cdx: add support for bus enable and disable cdx: Register cdx bus as a device on cdx subsystem cdx: Create symbol namespaces for cdx subsystem cdx: Introduce lock to protect controller ops cdx: Remove cdx controller list from cdx bus system dts: ti: k3-am625-beagleplay: Add beaglecc1352 greybus: Add BeaglePlay Linux Driver dt-bindings: net: Add ti,cc1352p7 dt-bindings: eeprom: at24: allow NVMEM cells based on old syntax dt-bindings: nvmem: SID: allow NVMEM cells based on old syntax Revert "nvmem: add new config option" MAINTAINERS: coresight: Add missing Coresight files misc: pci_endpoint_test: Add deviceID for J721S2 PCIe EP device support firmware: xilinx: Move EXPORT_SYMBOL_GPL next to zynqmp_pm_feature definition uacce: make uacce_class constant ocxl: make ocxl_class constant cxl: make cxl_class constant misc: phantom: make phantom_class constant ...
Diffstat (limited to 'drivers/parport')
-rw-r--r--drivers/parport/procfs.c53
-rw-r--r--drivers/parport/share.c26
2 files changed, 16 insertions, 63 deletions
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index 532d5cbbd3448..bd388560ed592 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -32,13 +32,6 @@
#define PARPORT_MAX_TIMESLICE_VALUE ((unsigned long) HZ)
#define PARPORT_MIN_SPINTIME_VALUE 1
#define PARPORT_MAX_SPINTIME_VALUE 1000
-/*
- * PARPORT_BASE_* is the size of the known parts of the sysctl path
- * in dev/partport/%s/devices/%s. "dev/parport/"(12), "/devices/"(9
- * and null char(1).
- */
-#define PARPORT_BASE_PATH_SIZE 13
-#define PARPORT_BASE_DEVICES_PATH_SIZE 22
static int do_active_device(struct ctl_table *table, int write,
void *result, size_t *lenp, loff_t *ppos)
@@ -423,8 +416,7 @@ int parport_proc_register(struct parport *port)
{
struct parport_sysctl_table *t;
char *tmp_dir_path;
- size_t tmp_path_len, port_name_len;
- int bytes_written, i, err = 0;
+ int i, err = 0;
t = kmemdup(&parport_sysctl_template, sizeof(*t), GFP_KERNEL);
if (t == NULL)
@@ -440,35 +432,23 @@ int parport_proc_register(struct parport *port)
#endif /* IEEE 1284 support */
}
- port_name_len = strnlen(port->name, PARPORT_NAME_MAX_LEN);
- /*
- * Allocate a buffer for two paths: dev/parport/PORT and dev/parport/PORT/devices.
- * We calculate for the second as that will give us enough for the first.
- */
- tmp_path_len = PARPORT_BASE_DEVICES_PATH_SIZE + port_name_len;
- tmp_dir_path = kzalloc(tmp_path_len, GFP_KERNEL);
+ tmp_dir_path = kasprintf(GFP_KERNEL, "dev/parport/%s/devices", port->name);
if (!tmp_dir_path) {
err = -ENOMEM;
goto exit_free_t;
}
- bytes_written = snprintf(tmp_dir_path, tmp_path_len,
- "dev/parport/%s/devices", port->name);
- if (tmp_path_len <= bytes_written) {
- err = -ENOENT;
- goto exit_free_tmp_dir_path;
- }
t->devices_header = register_sysctl(tmp_dir_path, t->device_dir);
if (t->devices_header == NULL) {
err = -ENOENT;
goto exit_free_tmp_dir_path;
}
- tmp_path_len = PARPORT_BASE_PATH_SIZE + port_name_len;
- bytes_written = snprintf(tmp_dir_path, tmp_path_len,
- "dev/parport/%s", port->name);
- if (tmp_path_len <= bytes_written) {
- err = -ENOENT;
+ kfree(tmp_dir_path);
+
+ tmp_dir_path = kasprintf(GFP_KERNEL, "dev/parport/%s", port->name);
+ if (!tmp_dir_path) {
+ err = -ENOMEM;
goto unregister_devices_h;
}
@@ -508,34 +488,22 @@ int parport_proc_unregister(struct parport *port)
int parport_device_proc_register(struct pardevice *device)
{
- int bytes_written, err = 0;
struct parport_device_sysctl_table *t;
struct parport * port = device->port;
- size_t port_name_len, device_name_len, tmp_dir_path_len;
char *tmp_dir_path;
+ int err = 0;
t = kmemdup(&parport_device_sysctl_template, sizeof(*t), GFP_KERNEL);
if (t == NULL)
return -ENOMEM;
- port_name_len = strnlen(port->name, PARPORT_NAME_MAX_LEN);
- device_name_len = strnlen(device->name, PATH_MAX);
-
/* Allocate a buffer for two paths: dev/parport/PORT/devices/DEVICE. */
- tmp_dir_path_len = PARPORT_BASE_DEVICES_PATH_SIZE + port_name_len + device_name_len;
- tmp_dir_path = kzalloc(tmp_dir_path_len, GFP_KERNEL);
+ tmp_dir_path = kasprintf(GFP_KERNEL, "dev/parport/%s/devices/%s", port->name, device->name);
if (!tmp_dir_path) {
err = -ENOMEM;
goto exit_free_t;
}
- bytes_written = snprintf(tmp_dir_path, tmp_dir_path_len, "dev/parport/%s/devices/%s",
- port->name, device->name);
- if (tmp_dir_path_len <= bytes_written) {
- err = -ENOENT;
- goto exit_free_path;
- }
-
t->vars[0].data = &device->timeslice;
t->sysctl_header = register_sysctl(tmp_dir_path, t->vars);
@@ -548,9 +516,6 @@ int parport_device_proc_register(struct pardevice *device)
kfree(tmp_dir_path);
return 0;
-exit_free_path:
- kfree(tmp_dir_path);
-
exit_free_t:
kfree(t);
diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 2d46b1d4fd695..e21831d93305d 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -361,7 +361,6 @@ static void free_port(struct device *dev)
kfree(port->probe_info[d].description);
}
- kfree(port->name);
kfree(port);
}
@@ -438,7 +437,6 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
struct parport *tmp;
int num;
int device;
- char *name;
int ret;
tmp = kzalloc(sizeof(struct parport), GFP_KERNEL);
@@ -450,13 +448,9 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
tmp->irq = irq;
tmp->dma = dma;
tmp->muxport = tmp->daisy = tmp->muxsel = -1;
- tmp->modes = 0;
INIT_LIST_HEAD(&tmp->list);
- tmp->devices = tmp->cad = NULL;
- tmp->flags = 0;
tmp->ops = ops;
tmp->physport = tmp;
- memset(tmp->probe_info, 0, 5 * sizeof(struct parport_device_info));
rwlock_init(&tmp->cad_lock);
spin_lock_init(&tmp->waitlist_lock);
spin_lock_init(&tmp->pardevice_lock);
@@ -465,19 +459,15 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
sema_init(&tmp->ieee1284.irq, 0);
tmp->spintime = parport_default_spintime;
atomic_set(&tmp->ref_count, 1);
- INIT_LIST_HEAD(&tmp->full_list);
- name = kmalloc(PARPORT_NAME_MAX_LEN, GFP_KERNEL);
- if (!name) {
- kfree(tmp);
- return NULL;
- }
/* Search for the lowest free parport number. */
spin_lock(&full_list_lock);
- for (l = all_ports.next, num = 0; l != &all_ports; l = l->next, num++) {
+ num = 0;
+ list_for_each(l, &all_ports) {
struct parport *p = list_entry(l, struct parport, full_list);
- if (p->number != num)
+
+ if (p->number != num++)
break;
}
tmp->portnum = tmp->number = num;
@@ -487,19 +477,17 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
/*
* Now that the portnum is known finish doing the Init.
*/
- sprintf(name, "parport%d", tmp->portnum = tmp->number);
- tmp->name = name;
+ dev_set_name(&tmp->bus_dev, "parport%d", tmp->portnum);
tmp->bus_dev.bus = &parport_bus_type;
tmp->bus_dev.release = free_port;
- dev_set_name(&tmp->bus_dev, name);
tmp->bus_dev.type = &parport_device_type;
+ tmp->name = dev_name(&tmp->bus_dev);
+
for (device = 0; device < 5; device++)
/* assume the worst */
tmp->probe_info[device].class = PARPORT_CLASS_LEGACY;
- tmp->waithead = tmp->waittail = NULL;
-
ret = device_register(&tmp->bus_dev);
if (ret) {
put_device(&tmp->bus_dev);