diff options
author | Joe Perches <joe@perches.com> | 2013-09-11 17:25:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:59:32 -0400 |
commit | fa63c0ab81f55eb5a016c1bcea04fe39c14afbaa (patch) | |
tree | 38bb69780f2fdb1935ac2471f101f1f60016d4fa /drivers/block | |
parent | 844aa7974395df1f0c7a866007e900e5f979fc7b (diff) |
pktcdvd: add struct pktcdvd_device.name to pr_err logging where possible
Add a new pkt_err macro to prefix the name to the logging output. Convert
pr_err where there is a non-null struct pktcdvd_device.
Includes improvements from Andy Shevchenko.
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/pktcdvd.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 5050c7abb6ee..3dbe42fe1bdd 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -71,6 +71,9 @@ | |||
71 | 71 | ||
72 | #define DRIVER_NAME "pktcdvd" | 72 | #define DRIVER_NAME "pktcdvd" |
73 | 73 | ||
74 | #define pkt_err(pd, fmt, ...) \ | ||
75 | pr_err("%s: " fmt, pd->name, ##__VA_ARGS__) | ||
76 | |||
74 | #define pkt_dbg(level, pd, fmt, ...) \ | 77 | #define pkt_dbg(level, pd, fmt, ...) \ |
75 | do { \ | 78 | do { \ |
76 | if (level == 2 && PACKET_DEBUG >= 2) \ | 79 | if (level == 2 && PACKET_DEBUG >= 2) \ |
@@ -938,7 +941,7 @@ static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_que | |||
938 | set_bit(PACKET_MERGE_SEGS, &pd->flags); | 941 | set_bit(PACKET_MERGE_SEGS, &pd->flags); |
939 | return 0; | 942 | return 0; |
940 | } else { | 943 | } else { |
941 | pr_err("cdrom max_phys_segments too small\n"); | 944 | pkt_err(pd, "cdrom max_phys_segments too small\n"); |
942 | return -EIO; | 945 | return -EIO; |
943 | } | 946 | } |
944 | } | 947 | } |
@@ -1743,7 +1746,7 @@ static noinline_for_stack int pkt_set_write_settings(struct pktcdvd_device *pd) | |||
1743 | /* | 1746 | /* |
1744 | * paranoia | 1747 | * paranoia |
1745 | */ | 1748 | */ |
1746 | pr_err("write mode wrong %d\n", wp->data_block_type); | 1749 | pkt_err(pd, "write mode wrong %d\n", wp->data_block_type); |
1747 | return 1; | 1750 | return 1; |
1748 | } | 1751 | } |
1749 | wp->packet_size = cpu_to_be32(pd->settings.size >> 2); | 1752 | wp->packet_size = cpu_to_be32(pd->settings.size >> 2); |
@@ -1787,7 +1790,7 @@ static int pkt_writable_track(struct pktcdvd_device *pd, track_information *ti) | |||
1787 | if (ti->rt == 1 && ti->blank == 0) | 1790 | if (ti->rt == 1 && ti->blank == 0) |
1788 | return 1; | 1791 | return 1; |
1789 | 1792 | ||
1790 | pr_err("bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet); | 1793 | pkt_err(pd, "bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet); |
1791 | return 0; | 1794 | return 0; |
1792 | } | 1795 | } |
1793 | 1796 | ||
@@ -1820,7 +1823,7 @@ static int pkt_writable_disc(struct pktcdvd_device *pd, disc_information *di) | |||
1820 | } | 1823 | } |
1821 | 1824 | ||
1822 | if (di->disc_type != 0x20 && di->disc_type != 0) { | 1825 | if (di->disc_type != 0x20 && di->disc_type != 0) { |
1823 | pr_err("wrong disc type (%x)\n", di->disc_type); | 1826 | pkt_err(pd, "wrong disc type (%x)\n", di->disc_type); |
1824 | return 0; | 1827 | return 0; |
1825 | } | 1828 | } |
1826 | 1829 | ||
@@ -1830,7 +1833,7 @@ static int pkt_writable_disc(struct pktcdvd_device *pd, disc_information *di) | |||
1830 | } | 1833 | } |
1831 | 1834 | ||
1832 | if (di->border_status == PACKET_SESSION_RESERVED) { | 1835 | if (di->border_status == PACKET_SESSION_RESERVED) { |
1833 | pr_err("can't write to last track (reserved)\n"); | 1836 | pkt_err(pd, "can't write to last track (reserved)\n"); |
1834 | return 0; | 1837 | return 0; |
1835 | } | 1838 | } |
1836 | 1839 | ||
@@ -1855,7 +1858,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd) | |||
1855 | memset(&ti, 0, sizeof(track_information)); | 1858 | memset(&ti, 0, sizeof(track_information)); |
1856 | 1859 | ||
1857 | if ((ret = pkt_get_disc_info(pd, &di))) { | 1860 | if ((ret = pkt_get_disc_info(pd, &di))) { |
1858 | pr_err("failed get_disc\n"); | 1861 | pkt_err(pd, "failed get_disc\n"); |
1859 | return ret; | 1862 | return ret; |
1860 | } | 1863 | } |
1861 | 1864 | ||
@@ -1866,12 +1869,12 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd) | |||
1866 | 1869 | ||
1867 | track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */ | 1870 | track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */ |
1868 | if ((ret = pkt_get_track_info(pd, track, 1, &ti))) { | 1871 | if ((ret = pkt_get_track_info(pd, track, 1, &ti))) { |
1869 | pr_err("failed get_track\n"); | 1872 | pkt_err(pd, "failed get_track\n"); |
1870 | return ret; | 1873 | return ret; |
1871 | } | 1874 | } |
1872 | 1875 | ||
1873 | if (!pkt_writable_track(pd, &ti)) { | 1876 | if (!pkt_writable_track(pd, &ti)) { |
1874 | pr_err("can't write to this track\n"); | 1877 | pkt_err(pd, "can't write to this track\n"); |
1875 | return -EROFS; | 1878 | return -EROFS; |
1876 | } | 1879 | } |
1877 | 1880 | ||
@@ -1885,7 +1888,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd) | |||
1885 | return -ENXIO; | 1888 | return -ENXIO; |
1886 | } | 1889 | } |
1887 | if (pd->settings.size > PACKET_MAX_SECTORS) { | 1890 | if (pd->settings.size > PACKET_MAX_SECTORS) { |
1888 | pr_err("packet size is too big\n"); | 1891 | pkt_err(pd, "packet size is too big\n"); |
1889 | return -EROFS; | 1892 | return -EROFS; |
1890 | } | 1893 | } |
1891 | pd->settings.fp = ti.fp; | 1894 | pd->settings.fp = ti.fp; |
@@ -1927,7 +1930,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd) | |||
1927 | pd->settings.block_mode = PACKET_BLOCK_MODE2; | 1930 | pd->settings.block_mode = PACKET_BLOCK_MODE2; |
1928 | break; | 1931 | break; |
1929 | default: | 1932 | default: |
1930 | pr_err("unknown data mode\n"); | 1933 | pkt_err(pd, "unknown data mode\n"); |
1931 | return -EROFS; | 1934 | return -EROFS; |
1932 | } | 1935 | } |
1933 | return 0; | 1936 | return 0; |
@@ -1961,7 +1964,7 @@ static noinline_for_stack int pkt_write_caching(struct pktcdvd_device *pd, | |||
1961 | cgc.buflen = cgc.cmd[8] = 2 + ((buf[0] << 8) | (buf[1] & 0xff)); | 1964 | cgc.buflen = cgc.cmd[8] = 2 + ((buf[0] << 8) | (buf[1] & 0xff)); |
1962 | ret = pkt_mode_select(pd, &cgc); | 1965 | ret = pkt_mode_select(pd, &cgc); |
1963 | if (ret) { | 1966 | if (ret) { |
1964 | pr_err("write caching control failed\n"); | 1967 | pkt_err(pd, "write caching control failed\n"); |
1965 | pkt_dump_sense(&cgc); | 1968 | pkt_dump_sense(&cgc); |
1966 | } else if (!ret && set) | 1969 | } else if (!ret && set) |
1967 | pr_notice("enabled write caching on %s\n", pd->name); | 1970 | pr_notice("enabled write caching on %s\n", pd->name); |
@@ -2200,7 +2203,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write) | |||
2200 | goto out; | 2203 | goto out; |
2201 | 2204 | ||
2202 | if ((ret = pkt_get_last_written(pd, &lba))) { | 2205 | if ((ret = pkt_get_last_written(pd, &lba))) { |
2203 | pr_err("pkt_get_last_written failed\n"); | 2206 | pkt_err(pd, "pkt_get_last_written failed\n"); |
2204 | goto out_putdev; | 2207 | goto out_putdev; |
2205 | } | 2208 | } |
2206 | 2209 | ||
@@ -2230,7 +2233,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write) | |||
2230 | 2233 | ||
2231 | if (write) { | 2234 | if (write) { |
2232 | if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) { | 2235 | if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) { |
2233 | pr_err("not enough memory for buffers\n"); | 2236 | pkt_err(pd, "not enough memory for buffers\n"); |
2234 | ret = -ENOMEM; | 2237 | ret = -ENOMEM; |
2235 | goto out_putdev; | 2238 | goto out_putdev; |
2236 | } | 2239 | } |
@@ -2352,8 +2355,8 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio) | |||
2352 | 2355 | ||
2353 | pd = q->queuedata; | 2356 | pd = q->queuedata; |
2354 | if (!pd) { | 2357 | if (!pd) { |
2355 | pr_err("%s incorrect request queue\n", | 2358 | pkt_err(pd, "%s incorrect request queue\n", |
2356 | bdevname(bio->bi_bdev, b)); | 2359 | bdevname(bio->bi_bdev, b)); |
2357 | goto end_io; | 2360 | goto end_io; |
2358 | } | 2361 | } |
2359 | 2362 | ||
@@ -2381,7 +2384,7 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio) | |||
2381 | } | 2384 | } |
2382 | 2385 | ||
2383 | if (!bio->bi_size || (bio->bi_size % CD_FRAMESIZE)) { | 2386 | if (!bio->bi_size || (bio->bi_size % CD_FRAMESIZE)) { |
2384 | pr_err("wrong bio size\n"); | 2387 | pkt_err(pd, "wrong bio size\n"); |
2385 | goto end_io; | 2388 | goto end_io; |
2386 | } | 2389 | } |
2387 | 2390 | ||
@@ -2602,7 +2605,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) | |||
2602 | struct block_device *bdev; | 2605 | struct block_device *bdev; |
2603 | 2606 | ||
2604 | if (pd->pkt_dev == dev) { | 2607 | if (pd->pkt_dev == dev) { |
2605 | pr_err("recursive setup not allowed\n"); | 2608 | pkt_err(pd, "recursive setup not allowed\n"); |
2606 | return -EBUSY; | 2609 | return -EBUSY; |
2607 | } | 2610 | } |
2608 | for (i = 0; i < MAX_WRITERS; i++) { | 2611 | for (i = 0; i < MAX_WRITERS; i++) { |
@@ -2610,11 +2613,12 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) | |||
2610 | if (!pd2) | 2613 | if (!pd2) |
2611 | continue; | 2614 | continue; |
2612 | if (pd2->bdev->bd_dev == dev) { | 2615 | if (pd2->bdev->bd_dev == dev) { |
2613 | pr_err("%s already setup\n", bdevname(pd2->bdev, b)); | 2616 | pkt_err(pd, "%s already setup\n", |
2617 | bdevname(pd2->bdev, b)); | ||
2614 | return -EBUSY; | 2618 | return -EBUSY; |
2615 | } | 2619 | } |
2616 | if (pd2->pkt_dev == dev) { | 2620 | if (pd2->pkt_dev == dev) { |
2617 | pr_err("can't chain pktcdvd devices\n"); | 2621 | pkt_err(pd, "can't chain pktcdvd devices\n"); |
2618 | return -EBUSY; | 2622 | return -EBUSY; |
2619 | } | 2623 | } |
2620 | } | 2624 | } |
@@ -2637,7 +2641,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev) | |||
2637 | atomic_set(&pd->cdrw.pending_bios, 0); | 2641 | atomic_set(&pd->cdrw.pending_bios, 0); |
2638 | pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name); | 2642 | pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name); |
2639 | if (IS_ERR(pd->cdrw.thread)) { | 2643 | if (IS_ERR(pd->cdrw.thread)) { |
2640 | pr_err("can't start kernel thread\n"); | 2644 | pkt_err(pd, "can't start kernel thread\n"); |
2641 | ret = -ENOMEM; | 2645 | ret = -ENOMEM; |
2642 | goto out_mem; | 2646 | goto out_mem; |
2643 | } | 2647 | } |