Re: [patch 2.6.28-rc6-davinci1 5/6] dm355evm input driver

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

 



On Sun, Dec 07, 2008 at 12:28:38PM -0800, David Brownell wrote:
> On Sunday 07 December 2008, Felipe Balbi wrote:
> > > +     platform_set_drvdata(pdev, keys);
> > > +     keys->pdev = pdev;
> > 
> > you could be holding only the device pointer.
> > 
> >         keys->dev = &pdev->dev;
> > 
> > then, if you really happen to need the pdev pointer you can use
> > 
> > to_platform_device(keys->dev);
> 
> True, that would be a bit simpler; the device handle is what's
> normally needed, e.g. for dev_dbg().  I'd take an update patch;
> but for now I'll avoid a re-test cycle.  :)

Here's an update patch for your input driver:

================ cut here ===================

diff --git a/drivers/input/keyboard/dm355evm_keys.c b/drivers/input/keyboard/dm355evm_keys.c
index ed36127..0871d9c 100644
--- a/drivers/input/keyboard/dm355evm_keys.c
+++ b/drivers/input/keyboard/dm355evm_keys.c
@@ -33,7 +33,7 @@
 struct dm355evm_keys {
 	struct work_struct	work;
 	struct input_dev	*input;
-	struct platform_device	*pdev;
+	struct device		*dev;
 	int			irq;
 };
 
@@ -128,7 +128,7 @@ static void dm355evm_keys_work(struct work_struct *work)
 
 		status = dm355evm_msp_read(DM355EVM_MSP_INPUT_HIGH);
 		if (status < 0) {
-			dev_dbg(&keys->pdev->dev, "input high err %d\n",
+			dev_dbg(keys->dev, "input high err %d\n",
 					status);
 			break;
 		}
@@ -136,7 +136,7 @@ static void dm355evm_keys_work(struct work_struct *work)
 
 		status = dm355evm_msp_read(DM355EVM_MSP_INPUT_LOW);
 		if (status < 0) {
-			dev_dbg(&keys->pdev->dev, "input low err %d\n",
+			dev_dbg(keys->dev, "input low err %d\n",
 					status);
 			break;
 		}
@@ -155,7 +155,7 @@ static void dm355evm_keys_work(struct work_struct *work)
 			keycode = dm355evm_keys[i].keycode;
 			break;
 		}
-		dev_dbg(&keys->pdev->dev,
+		dev_dbg(keys->dev,
 			"input event 0x%04x--> keycode %d\n",
 			event, keycode);
 
@@ -200,7 +200,7 @@ static int __devinit dm355evm_keys_probe(struct platform_device *pdev)
 	if (!keys)
 		goto fail0;
 	platform_set_drvdata(pdev, keys);
-	keys->pdev = pdev;
+	keys->dev = &pdev->dev;
 
 	/* ... and input dev ... */
 	input = input_allocate_device();
@@ -257,6 +257,7 @@ fail1:
 fail0:
 	kfree(keys);
 	dev_err(&pdev->dev, "can't register, err %d\n", status);
+
 	return status;
 }
 
@@ -267,6 +268,7 @@ static int __devexit dm355evm_keys_remove(struct platform_device *pdev)
 	free_irq(keys->irq, keys);
 	input_unregister_device(keys->input);
 	kfree(keys);
+
 	return 0;
 }
 

-- 
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux