aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/irda
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-10-25 07:25:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-10-25 07:25:22 -0400
commit8a9ea3237e7eb5c25f09e429ad242ae5a3d5ea22 (patch)
treea0a63398a9983667d52cbbbf4e2405b4f22b1d83 /drivers/net/irda
parent1be025d3cb40cd295123af2c394f7229ef9b30ca (diff)
parent8b3408f8ee994973869d8ba32c5bf482bc4ddca4 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1745 commits) dp83640: free packet queues on remove dp83640: use proper function to free transmit time stamping packets ipv6: Do not use routes from locally generated RAs |PATCH net-next] tg3: add tx_dropped counter be2net: don't create multiple RX/TX rings in multi channel mode be2net: don't create multiple TXQs in BE2 be2net: refactor VF setup/teardown code into be_vf_setup/clear() be2net: add vlan/rx-mode/flow-control config to be_setup() net_sched: cls_flow: use skb_header_pointer() ipv4: avoid useless call of the function check_peer_pmtu TCP: remove TCP_DEBUG net: Fix driver name for mdio-gpio.c ipv4: tcp: fix TOS value in ACK messages sent from TIME_WAIT rtnetlink: Add missing manual netlink notification in dev_change_net_namespaces ipv4: fix ipsec forward performance regression jme: fix irq storm after suspend/resume route: fix ICMP redirect validation net: hold sock reference while processing tx timestamps tcp: md5: add more const attributes Add ethtool -g support to virtio_net ... Fix up conflicts in: - drivers/net/Kconfig: The split-up generated a trivial conflict with removal of a stale reference to Documentation/networking/net-modules.txt. Remove it from the new location instead. - fs/sysfs/dir.c: Fairly nasty conflicts with the sysfs rb-tree usage, conflicting with Eric Biederman's changes for tagged directories.
Diffstat (limited to 'drivers/net/irda')
-rw-r--r--drivers/net/irda/sh_irda.c124
1 files changed, 70 insertions, 54 deletions
diff --git a/drivers/net/irda/sh_irda.c b/drivers/net/irda/sh_irda.c
index 82660672dcd9..d275e276e742 100644
--- a/drivers/net/irda/sh_irda.c
+++ b/drivers/net/irda/sh_irda.c
@@ -2,7 +2,7 @@
2 * SuperH IrDA Driver 2 * SuperH IrDA Driver
3 * 3 *
4 * Copyright (C) 2010 Renesas Solutions Corp. 4 * Copyright (C) 2010 Renesas Solutions Corp.
5 * Kuninori Morimoto <morimoto.kuninori@renesas.com> 5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 * 6 *
7 * Based on sh_sir.c 7 * Based on sh_sir.c
8 * Copyright (C) 2009 Renesas Solutions Corp. 8 * Copyright (C) 2009 Renesas Solutions Corp.
@@ -26,6 +26,7 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/pm_runtime.h>
29#include <linux/clk.h> 30#include <linux/clk.h>
30#include <net/irda/wrapper.h> 31#include <net/irda/wrapper.h>
31#include <net/irda/irda_device.h> 32#include <net/irda/irda_device.h>
@@ -144,8 +145,8 @@ struct sh_irda_xir_func {
144 145
145struct sh_irda_self { 146struct sh_irda_self {
146 void __iomem *membase; 147 void __iomem *membase;
147 unsigned int irq; 148 unsigned int irq;
148 struct clk *clk; 149 struct platform_device *pdev;
149 150
150 struct net_device *ndev; 151 struct net_device *ndev;
151 152
@@ -264,7 +265,7 @@ static int sh_irda_set_baudrate(struct sh_irda_self *self, int baudrate)
264 return 0; 265 return 0;
265} 266}
266 267
267static int xir_get_rcv_length(struct sh_irda_self *self) 268static int sh_irda_get_rcv_length(struct sh_irda_self *self)
268{ 269{
269 return RFL_MASK & sh_irda_read(self, IRRFLR); 270 return RFL_MASK & sh_irda_read(self, IRRFLR);
270} 271}
@@ -274,47 +275,47 @@ static int xir_get_rcv_length(struct sh_irda_self *self)
274 * NONE MODE 275 * NONE MODE
275 * 276 *
276 *=====================================*/ 277 *=====================================*/
277static int xir_fre(struct sh_irda_self *self) 278static int sh_irda_xir_fre(struct sh_irda_self *self)
278{ 279{
279 struct device *dev = &self->ndev->dev; 280 struct device *dev = &self->ndev->dev;
280 dev_err(dev, "none mode: frame recv\n"); 281 dev_err(dev, "none mode: frame recv\n");
281 return 0; 282 return 0;
282} 283}
283 284
284static int xir_trov(struct sh_irda_self *self) 285static int sh_irda_xir_trov(struct sh_irda_self *self)
285{ 286{
286 struct device *dev = &self->ndev->dev; 287 struct device *dev = &self->ndev->dev;
287 dev_err(dev, "none mode: buffer ram over\n"); 288 dev_err(dev, "none mode: buffer ram over\n");
288 return 0; 289 return 0;
289} 290}
290 291
291static int xir_9(struct sh_irda_self *self) 292static int sh_irda_xir_9(struct sh_irda_self *self)
292{ 293{
293 struct device *dev = &self->ndev->dev; 294 struct device *dev = &self->ndev->dev;
294 dev_err(dev, "none mode: time over\n"); 295 dev_err(dev, "none mode: time over\n");
295 return 0; 296 return 0;
296} 297}
297 298
298static int xir_8(struct sh_irda_self *self) 299static int sh_irda_xir_8(struct sh_irda_self *self)
299{ 300{
300 struct device *dev = &self->ndev->dev; 301 struct device *dev = &self->ndev->dev;
301 dev_err(dev, "none mode: framing error\n"); 302 dev_err(dev, "none mode: framing error\n");
302 return 0; 303 return 0;
303} 304}
304 305
305static int xir_fte(struct sh_irda_self *self) 306static int sh_irda_xir_fte(struct sh_irda_self *self)
306{ 307{
307 struct device *dev = &self->ndev->dev; 308 struct device *dev = &self->ndev->dev;
308 dev_err(dev, "none mode: frame transmit end\n"); 309 dev_err(dev, "none mode: frame transmit end\n");
309 return 0; 310 return 0;
310} 311}
311 312
312static struct sh_irda_xir_func xir_func = { 313static struct sh_irda_xir_func sh_irda_xir_func = {
313 .xir_fre = xir_fre, 314 .xir_fre = sh_irda_xir_fre,
314 .xir_trov = xir_trov, 315 .xir_trov = sh_irda_xir_trov,
315 .xir_9 = xir_9, 316 .xir_9 = sh_irda_xir_9,
316 .xir_8 = xir_8, 317 .xir_8 = sh_irda_xir_8,
317 .xir_fte = xir_fte, 318 .xir_fte = sh_irda_xir_fte,
318}; 319};
319 320
320/*===================================== 321/*=====================================
@@ -323,12 +324,12 @@ static struct sh_irda_xir_func xir_func = {
323 * 324 *
324 * MIR/FIR are not supported now 325 * MIR/FIR are not supported now
325 *=====================================*/ 326 *=====================================*/
326static struct sh_irda_xir_func mfir_func = { 327static struct sh_irda_xir_func sh_irda_mfir_func = {
327 .xir_fre = xir_fre, 328 .xir_fre = sh_irda_xir_fre,
328 .xir_trov = xir_trov, 329 .xir_trov = sh_irda_xir_trov,
329 .xir_9 = xir_9, 330 .xir_9 = sh_irda_xir_9,
330 .xir_8 = xir_8, 331 .xir_8 = sh_irda_xir_8,
331 .xir_fte = xir_fte, 332 .xir_fte = sh_irda_xir_fte,
332}; 333};
333 334
334/*===================================== 335/*=====================================
@@ -336,12 +337,12 @@ static struct sh_irda_xir_func mfir_func = {
336 * SIR MODE 337 * SIR MODE
337 * 338 *
338 *=====================================*/ 339 *=====================================*/
339static int sir_fre(struct sh_irda_self *self) 340static int sh_irda_sir_fre(struct sh_irda_self *self)
340{ 341{
341 struct device *dev = &self->ndev->dev; 342 struct device *dev = &self->ndev->dev;
342 u16 data16; 343 u16 data16;
343 u8 *data = (u8 *)&data16; 344 u8 *data = (u8 *)&data16;
344 int len = xir_get_rcv_length(self); 345 int len = sh_irda_get_rcv_length(self);
345 int i, j; 346 int i, j;
346 347
347 if (len > IRDARAM_LEN) 348 if (len > IRDARAM_LEN)
@@ -364,7 +365,7 @@ static int sir_fre(struct sh_irda_self *self)
364 return 0; 365 return 0;
365} 366}
366 367
367static int sir_trov(struct sh_irda_self *self) 368static int sh_irda_sir_trov(struct sh_irda_self *self)
368{ 369{
369 struct device *dev = &self->ndev->dev; 370 struct device *dev = &self->ndev->dev;
370 371
@@ -373,7 +374,7 @@ static int sir_trov(struct sh_irda_self *self)
373 return 0; 374 return 0;
374} 375}
375 376
376static int sir_tot(struct sh_irda_self *self) 377static int sh_irda_sir_tot(struct sh_irda_self *self)
377{ 378{
378 struct device *dev = &self->ndev->dev; 379 struct device *dev = &self->ndev->dev;
379 380
@@ -383,7 +384,7 @@ static int sir_tot(struct sh_irda_self *self)
383 return 0; 384 return 0;
384} 385}
385 386
386static int sir_fer(struct sh_irda_self *self) 387static int sh_irda_sir_fer(struct sh_irda_self *self)
387{ 388{
388 struct device *dev = &self->ndev->dev; 389 struct device *dev = &self->ndev->dev;
389 390
@@ -392,7 +393,7 @@ static int sir_fer(struct sh_irda_self *self)
392 return 0; 393 return 0;
393} 394}
394 395
395static int sir_fte(struct sh_irda_self *self) 396static int sh_irda_sir_fte(struct sh_irda_self *self)
396{ 397{
397 struct device *dev = &self->ndev->dev; 398 struct device *dev = &self->ndev->dev;
398 399
@@ -402,12 +403,12 @@ static int sir_fte(struct sh_irda_self *self)
402 return 0; 403 return 0;
403} 404}
404 405
405static struct sh_irda_xir_func sir_func = { 406static struct sh_irda_xir_func sh_irda_sir_func = {
406 .xir_fre = sir_fre, 407 .xir_fre = sh_irda_sir_fre,
407 .xir_trov = sir_trov, 408 .xir_trov = sh_irda_sir_trov,
408 .xir_9 = sir_tot, 409 .xir_9 = sh_irda_sir_tot,
409 .xir_8 = sir_fer, 410 .xir_8 = sh_irda_sir_fer,
410 .xir_fte = sir_fte, 411 .xir_fte = sh_irda_sir_fte,
411}; 412};
412 413
413static void sh_irda_set_mode(struct sh_irda_self *self, enum sh_irda_mode mode) 414static void sh_irda_set_mode(struct sh_irda_self *self, enum sh_irda_mode mode)
@@ -421,22 +422,22 @@ static void sh_irda_set_mode(struct sh_irda_self *self, enum sh_irda_mode mode)
421 case SH_IRDA_SIR: 422 case SH_IRDA_SIR:
422 name = "SIR"; 423 name = "SIR";
423 data = TMD_SIR; 424 data = TMD_SIR;
424 func = &sir_func; 425 func = &sh_irda_sir_func;
425 break; 426 break;
426 case SH_IRDA_MIR: 427 case SH_IRDA_MIR:
427 name = "MIR"; 428 name = "MIR";
428 data = TMD_MIR; 429 data = TMD_MIR;
429 func = &mfir_func; 430 func = &sh_irda_mfir_func;
430 break; 431 break;
431 case SH_IRDA_FIR: 432 case SH_IRDA_FIR:
432 name = "FIR"; 433 name = "FIR";
433 data = TMD_FIR; 434 data = TMD_FIR;
434 func = &mfir_func; 435 func = &sh_irda_mfir_func;
435 break; 436 break;
436 default: 437 default:
437 name = "NONE"; 438 name = "NONE";
438 data = 0; 439 data = 0;
439 func = &xir_func; 440 func = &sh_irda_xir_func;
440 break; 441 break;
441 } 442 }
442 443
@@ -694,7 +695,7 @@ static int sh_irda_open(struct net_device *ndev)
694 struct sh_irda_self *self = netdev_priv(ndev); 695 struct sh_irda_self *self = netdev_priv(ndev);
695 int err; 696 int err;
696 697
697 clk_enable(self->clk); 698 pm_runtime_get_sync(&self->pdev->dev);
698 err = sh_irda_crc_init(self); 699 err = sh_irda_crc_init(self);
699 if (err) 700 if (err)
700 goto open_err; 701 goto open_err;
@@ -718,7 +719,7 @@ static int sh_irda_open(struct net_device *ndev)
718 return 0; 719 return 0;
719 720
720open_err: 721open_err:
721 clk_disable(self->clk); 722 pm_runtime_put_sync(&self->pdev->dev);
722 723
723 return err; 724 return err;
724} 725}
@@ -734,6 +735,7 @@ static int sh_irda_stop(struct net_device *ndev)
734 } 735 }
735 736
736 netif_stop_queue(ndev); 737 netif_stop_queue(ndev);
738 pm_runtime_put_sync(&self->pdev->dev);
737 739
738 dev_info(&ndev->dev, "stoped\n"); 740 dev_info(&ndev->dev, "stoped\n");
739 741
@@ -786,11 +788,8 @@ static int __devinit sh_irda_probe(struct platform_device *pdev)
786 if (err) 788 if (err)
787 goto err_mem_2; 789 goto err_mem_2;
788 790
789 self->clk = clk_get(&pdev->dev, NULL); 791 self->pdev = pdev;
790 if (IS_ERR(self->clk)) { 792 pm_runtime_enable(&pdev->dev);
791 dev_err(&pdev->dev, "cannot get irda clock\n");
792 goto err_mem_3;
793 }
794 793
795 irda_init_max_qos_capabilies(&self->qos); 794 irda_init_max_qos_capabilies(&self->qos);
796 795
@@ -820,8 +819,7 @@ static int __devinit sh_irda_probe(struct platform_device *pdev)
820 goto exit; 819 goto exit;
821 820
822err_mem_4: 821err_mem_4:
823 clk_put(self->clk); 822 pm_runtime_disable(&pdev->dev);
824err_mem_3:
825 sh_irda_remove_iobuf(self); 823 sh_irda_remove_iobuf(self);
826err_mem_2: 824err_mem_2:
827 iounmap(self->membase); 825 iounmap(self->membase);
@@ -840,7 +838,7 @@ static int __devexit sh_irda_remove(struct platform_device *pdev)
840 return 0; 838 return 0;
841 839
842 unregister_netdev(ndev); 840 unregister_netdev(ndev);
843 clk_put(self->clk); 841 pm_runtime_disable(&pdev->dev);
844 sh_irda_remove_iobuf(self); 842 sh_irda_remove_iobuf(self);
845 iounmap(self->membase); 843 iounmap(self->membase);
846 free_netdev(ndev); 844 free_netdev(ndev);
@@ -849,11 +847,29 @@ static int __devexit sh_irda_remove(struct platform_device *pdev)
849 return 0; 847 return 0;
850} 848}
851 849
850static int sh_irda_runtime_nop(struct device *dev)
851{
852 /* Runtime PM callback shared between ->runtime_suspend()
853 * and ->runtime_resume(). Simply returns success.
854 *
855 * This driver re-initializes all registers after
856 * pm_runtime_get_sync() anyway so there is no need
857 * to save and restore registers here.
858 */
859 return 0;
860}
861
862static const struct dev_pm_ops sh_irda_pm_ops = {
863 .runtime_suspend = sh_irda_runtime_nop,
864 .runtime_resume = sh_irda_runtime_nop,
865};
866
852static struct platform_driver sh_irda_driver = { 867static struct platform_driver sh_irda_driver = {
853 .probe = sh_irda_probe, 868 .probe = sh_irda_probe,
854 .remove = __devexit_p(sh_irda_remove), 869 .remove = __devexit_p(sh_irda_remove),
855 .driver = { 870 .driver = {
856 .name = DRIVER_NAME, 871 .name = DRIVER_NAME,
872 .pm = &sh_irda_pm_ops,
857 }, 873 },
858}; 874};
859 875
@@ -870,6 +886,6 @@ static void __exit sh_irda_exit(void)
870module_init(sh_irda_init); 886module_init(sh_irda_init);
871module_exit(sh_irda_exit); 887module_exit(sh_irda_exit);
872 888
873MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>"); 889MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
874MODULE_DESCRIPTION("SuperH IrDA driver"); 890MODULE_DESCRIPTION("SuperH IrDA driver");
875MODULE_LICENSE("GPL"); 891MODULE_LICENSE("GPL");