* [PATCH 1/2] parport: daisy: use new parport device model
@ 2019-02-09 20:59 Sudip Mukherjee
2019-02-09 20:59 ` [PATCH 2/2] parport_pc: fix find_superio io compare code, should use equal test Sudip Mukherjee
2019-02-11 8:38 ` [PATCH 1/2] parport: daisy: use new parport device model Greg Kroah-Hartman
0 siblings, 2 replies; 3+ messages in thread
From: Sudip Mukherjee @ 2019-02-09 20:59 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, Sudip Mukherjee
Modify parport daisy driver to use the new parallel port device model.
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
drivers/parport/daisy.c | 32 +++++++++++++++++++++++++++++++-
drivers/parport/probe.c | 2 +-
drivers/parport/share.c | 14 +++++++++++++-
include/linux/parport.h | 3 +++
4 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c
index 5484a46dafda..56dd83a45e55 100644
--- a/drivers/parport/daisy.c
+++ b/drivers/parport/daisy.c
@@ -213,10 +213,12 @@ void parport_daisy_fini(struct parport *port)
struct pardevice *parport_open(int devnum, const char *name)
{
struct daisydev *p = topology;
+ struct pardev_cb par_cb;
struct parport *port;
struct pardevice *dev;
int daisy;
+ memset(&par_cb, 0, sizeof(par_cb));
spin_lock(&topology_lock);
while (p && p->devnum != devnum)
p = p->next;
@@ -230,7 +232,7 @@ struct pardevice *parport_open(int devnum, const char *name)
port = parport_get_port(p->port);
spin_unlock(&topology_lock);
- dev = parport_register_device(port, name, NULL, NULL, NULL, 0, NULL);
+ dev = parport_register_dev_model(port, name, &par_cb, devnum);
parport_put_port(port);
if (!dev)
return NULL;
@@ -480,3 +482,31 @@ static int assign_addrs(struct parport *port)
kfree(deviceid);
return detected;
}
+
+static int daisy_drv_probe(struct pardevice *par_dev)
+{
+ struct device_driver *drv = par_dev->dev.driver;
+
+ if (strcmp(drv->name, "daisy_drv"))
+ return -ENODEV;
+ if (strcmp(par_dev->name, daisy_dev_name))
+ return -ENODEV;
+
+ return 0;
+}
+
+static struct parport_driver daisy_driver = {
+ .name = "daisy_drv",
+ .probe = daisy_drv_probe,
+ .devmodel = true,
+};
+
+int daisy_drv_init(void)
+{
+ return parport_register_driver(&daisy_driver);
+}
+
+void daisy_drv_exit(void)
+{
+ parport_unregister_driver(&daisy_driver);
+}
diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index e035174ba205..e5e6a463a941 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -257,7 +257,7 @@ static ssize_t parport_read_device_id (struct parport *port, char *buffer,
ssize_t parport_device_id (int devnum, char *buffer, size_t count)
{
ssize_t retval = -ENXIO;
- struct pardevice *dev = parport_open (devnum, "Device ID probe");
+ struct pardevice *dev = parport_open(devnum, daisy_dev_name);
if (!dev)
return -ENXIO;
diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 5dc53d420ca8..b89560d53a35 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -137,11 +137,23 @@ static struct bus_type parport_bus_type = {
int parport_bus_init(void)
{
- return bus_register(&parport_bus_type);
+ int retval;
+
+ retval = bus_register(&parport_bus_type);
+ if (retval)
+ return retval;
+#ifdef CONFIG_PARPORT_1284
+ daisy_drv_init();
+#endif
+
+ return 0;
}
void parport_bus_exit(void)
{
+#ifdef CONFIG_PARPORT_1284
+ daisy_drv_exit();
+#endif
bus_unregister(&parport_bus_type);
}
diff --git a/include/linux/parport.h b/include/linux/parport.h
index 397607a0c0eb..e0992953ff2b 100644
--- a/include/linux/parport.h
+++ b/include/linux/parport.h
@@ -460,6 +460,7 @@ extern size_t parport_ieee1284_epp_read_addr (struct parport *,
void *, size_t, int);
/* IEEE1284.3 functions */
+#define daisy_dev_name "Device ID probe"
extern int parport_daisy_init (struct parport *port);
extern void parport_daisy_fini (struct parport *port);
extern struct pardevice *parport_open (int devnum, const char *name);
@@ -467,6 +468,8 @@ extern void parport_close (struct pardevice *dev);
extern ssize_t parport_device_id (int devnum, char *buffer, size_t len);
extern void parport_daisy_deselect_all (struct parport *port);
extern int parport_daisy_select (struct parport *port, int daisy, int mode);
+extern int daisy_drv_init(void);
+extern void daisy_drv_exit(void);
/* Lowlevel drivers _can_ call this support function to handle irqs. */
static inline void parport_generic_irq(struct parport *port)
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] parport_pc: fix find_superio io compare code, should use equal test.
2019-02-09 20:59 [PATCH 1/2] parport: daisy: use new parport device model Sudip Mukherjee
@ 2019-02-09 20:59 ` Sudip Mukherjee
2019-02-11 8:38 ` [PATCH 1/2] parport: daisy: use new parport device model Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Sudip Mukherjee @ 2019-02-09 20:59 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-kernel, QiaoChong, Alan Cox, stable, Sudip Mukherjee
From: QiaoChong <qiaochong@loongson.cn>
In the original code before 181bf1e815a2 the loop was continuing until
it finds the first matching superios[i].io and p->base.
But after 181bf1e815a2 the logic changed and the loop now returns the
pointer to the first mismatched array element which is then used in
get_superio_dma() and get_superio_irq() and thus returning the wrong
value.
Fix the condition so that it now returns the correct pointer.
Fixes: 181bf1e815a2 ("parport_pc: clean up the modified while loops using for")
Cc: Alan Cox <alan@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
[rewrite the commit message]
---
drivers/parport/parport_pc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 9c8249f74479..6296dbb83d47 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -1377,7 +1377,7 @@ static struct superio_struct *find_superio(struct parport *p)
{
int i;
for (i = 0; i < NR_SUPERIOS; i++)
- if (superios[i].io != p->base)
+ if (superios[i].io == p->base)
return &superios[i];
return NULL;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] parport: daisy: use new parport device model
2019-02-09 20:59 [PATCH 1/2] parport: daisy: use new parport device model Sudip Mukherjee
2019-02-09 20:59 ` [PATCH 2/2] parport_pc: fix find_superio io compare code, should use equal test Sudip Mukherjee
@ 2019-02-11 8:38 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2019-02-11 8:38 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: linux-kernel
On Sat, Feb 09, 2019 at 08:59:06PM +0000, Sudip Mukherjee wrote:
> - return bus_register(&parport_bus_type);
> + int retval;
> +
> + retval = bus_register(&parport_bus_type);
> + if (retval)
> + return retval;
> +#ifdef CONFIG_PARPORT_1284
> + daisy_drv_init();
> +#endif
Shouldn't you hide these #ifdef lines in the .h file instead of putting
them in the .c file?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-11 8:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-09 20:59 [PATCH 1/2] parport: daisy: use new parport device model Sudip Mukherjee
2019-02-09 20:59 ` [PATCH 2/2] parport_pc: fix find_superio io compare code, should use equal test Sudip Mukherjee
2019-02-11 8:38 ` [PATCH 1/2] parport: daisy: use new parport device model Greg Kroah-Hartman
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).