Skip to content

Commit da67529

Browse files
David BrownellLinus Torvalds
authored andcommitted
layered parport code uses parport->dev
Update some of the layered parport_driver code to use parport->dev: - i2c-parport (parent of i2c_adapter) - spi_butterfly (parent of spi_master, allowing cruft removal) - lp (creating class_device) - ppdev (parent of parportN device) - tipar (creating class_device) There are still drivers that should be updated, like some of the input drivers; but they won't be any worse off than they are today. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Cc: Greg KH <greg@kroah.com> Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a7d801a commit da67529

5 files changed

Lines changed: 8 additions & 20 deletions

File tree

‎drivers/char/lp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ static int lp_register(int nr, struct parport *port)
803803
if (reset)
804804
lp_reset(nr);
805805

806-
class_device_create(lp_class, NULL, MKDEV(LP_MAJOR, nr), NULL,
806+
class_device_create(lp_class, NULL, MKDEV(LP_MAJOR, nr), port->dev,
807807
"lp%d", nr);
808808

809809
printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,

‎drivers/char/ppdev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static const struct file_operations pp_fops = {
752752

753753
static void pp_attach(struct parport *port)
754754
{
755-
device_create(ppdev_class, NULL, MKDEV(PP_MAJOR, port->number),
755+
device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
756756
"parport%d", port->number);
757757
}
758758

‎drivers/char/tipar.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ tipar_register(int nr, struct parport *port)
442442
}
443443

444444
class_device_create(tipar_class, NULL, MKDEV(TIPAR_MAJOR,
445-
TIPAR_MINOR + nr), NULL, "par%d", nr);
445+
TIPAR_MINOR + nr), port->dev, "par%d", nr);
446446

447447
/* Display informations */
448448
pr_info("tipar%d: using %s (%s)\n", nr, port->name, (port->irq ==

‎drivers/i2c/busses/i2c-parport.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ static void i2c_parport_attach (struct parport *port)
175175
}
176176
adapter->algo_data.data = port;
177177
adapter->adapter.algo_data = &adapter->algo_data;
178+
adapter->adapter.dev.parent = port->physport->dev;
178179

179180
if (parport_claim_or_block(adapter->pdev) < 0) {
180181
printk(KERN_ERR "i2c-parport: Could not claim parallel port\n");

‎drivers/spi/spi_butterfly.c‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <linux/kernel.h>
2121
#include <linux/init.h>
2222
#include <linux/delay.h>
23-
#include <linux/platform_device.h>
23+
#include <linux/device.h>
2424
#include <linux/parport.h>
2525

2626
#include <linux/sched.h>
@@ -237,24 +237,16 @@ static void butterfly_attach(struct parport *p)
237237
int status;
238238
struct butterfly *pp;
239239
struct spi_master *master;
240-
struct platform_device *pdev;
240+
struct device *dev = p->physport->dev;
241241

242-
if (butterfly)
242+
if (butterfly || !dev)
243243
return;
244244

245245
/* REVISIT: this just _assumes_ a butterfly is there ... no probe,
246246
* and no way to be selective about what it binds to.
247247
*/
248248

249-
/* FIXME where should master->cdev.dev come from?
250-
* e.g. /sys/bus/pnp0/00:0b, some PCI thing, etc
251-
* setting up a platform device like this is an ugly kluge...
252-
*/
253-
pdev = platform_device_register_simple("butterfly", -1, NULL, 0);
254-
if (IS_ERR(pdev))
255-
return;
256-
257-
master = spi_alloc_master(&pdev->dev, sizeof *pp);
249+
master = spi_alloc_master(dev, sizeof *pp);
258250
if (!master) {
259251
status = -ENOMEM;
260252
goto done;
@@ -366,14 +358,12 @@ static void butterfly_attach(struct parport *p)
366358
clean0:
367359
(void) spi_master_put(pp->bitbang.master);
368360
done:
369-
platform_device_unregister(pdev);
370361
pr_debug("%s: butterfly probe, fail %d\n", p->name, status);
371362
}
372363

373364
static void butterfly_detach(struct parport *p)
374365
{
375366
struct butterfly *pp;
376-
struct platform_device *pdev;
377367
int status;
378368

379369
/* FIXME this global is ugly ... but, how to quickly get from
@@ -386,7 +376,6 @@ static void butterfly_detach(struct parport *p)
386376
butterfly = NULL;
387377

388378
/* stop() unregisters child devices too */
389-
pdev = to_platform_device(pp->bitbang.master->cdev.dev);
390379
status = spi_bitbang_stop(&pp->bitbang);
391380

392381
/* turn off VCC */
@@ -397,8 +386,6 @@ static void butterfly_detach(struct parport *p)
397386
parport_unregister_device(pp->pd);
398387

399388
(void) spi_master_put(pp->bitbang.master);
400-
401-
platform_device_unregister(pdev);
402389
}
403390

404391
static struct parport_driver butterfly_driver = {

0 commit comments

Comments
 (0)