aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-09-11 17:25:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:59:30 -0400
commit99481334bcab1330fce0c590b845b4a95b101a69 (patch)
treef8a20a2c2a78f78c196a9a515c318fe02002752a
parent5323fb770b6254a4c218a2dfb0ef9aa007b7725a (diff)
pktcdvd: convert printk to pr_<level>
Use a more current logging style and add messages levels to the logging messages. Simplify pkt_dump_sense by using %*ph and adding a simple function to emit the sense string. Includes improvements from Andy Shevchenko and Dan Carpenter. Signed-off-by: Joe Perches <joe@perches.com> Cc: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Dan Carpenter <dan.carpenter@oracle.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>
-rw-r--r--drivers/block/pktcdvd.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index aa18a2584249..eb71522c20ab 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -44,6 +44,8 @@
44 * 44 *
45 *************************************************************************/ 45 *************************************************************************/
46 46
47#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
48
47#include <linux/pktcdvd.h> 49#include <linux/pktcdvd.h>
48#include <linux/module.h> 50#include <linux/module.h>
49#include <linux/types.h> 51#include <linux/types.h>
@@ -424,7 +426,7 @@ static int pkt_sysfs_init(void)
424 if (ret) { 426 if (ret) {
425 kfree(class_pktcdvd); 427 kfree(class_pktcdvd);
426 class_pktcdvd = NULL; 428 class_pktcdvd = NULL;
427 printk(DRIVER_NAME": failed to create class pktcdvd\n"); 429 pr_err("failed to create class pktcdvd\n");
428 return ret; 430 return ret;
429 } 431 }
430 return 0; 432 return 0;
@@ -734,36 +736,32 @@ out:
734 return ret; 736 return ret;
735} 737}
736 738
739static const char *sense_key_string(__u8 index)
740{
741 static const char * const info[] = {
742 "No sense", "Recovered error", "Not ready",
743 "Medium error", "Hardware error", "Illegal request",
744 "Unit attention", "Data protect", "Blank check",
745 };
746
747 return index < ARRAY_SIZE(info) ? info[index] : "INVALID";
748}
749
737/* 750/*
738 * A generic sense dump / resolve mechanism should be implemented across 751 * A generic sense dump / resolve mechanism should be implemented across
739 * all ATAPI + SCSI devices. 752 * all ATAPI + SCSI devices.
740 */ 753 */
741static void pkt_dump_sense(struct packet_command *cgc) 754static void pkt_dump_sense(struct packet_command *cgc)
742{ 755{
743 static char *info[9] = { "No sense", "Recovered error", "Not ready",
744 "Medium error", "Hardware error", "Illegal request",
745 "Unit attention", "Data protect", "Blank check" };
746 int i;
747 struct request_sense *sense = cgc->sense; 756 struct request_sense *sense = cgc->sense;
748 757
749 printk(DRIVER_NAME":"); 758 if (sense)
750 for (i = 0; i < CDROM_PACKET_SIZE; i++) 759 pr_err("%*ph - sense %02x.%02x.%02x (%s)\n",
751 printk(" %02x", cgc->cmd[i]); 760 CDROM_PACKET_SIZE, cgc->cmd,
752 printk(" - "); 761 sense->sense_key, sense->asc, sense->ascq,
753 762 sense_key_string(sense->sense_key));
754 if (sense == NULL) { 763 else
755 printk("no sense\n"); 764 pr_err("%*ph - no sense\n", CDROM_PACKET_SIZE, cgc->cmd);
756 return;
757 }
758
759 printk("sense %02x.%02x.%02x", sense->sense_key, sense->asc, sense->ascq);
760
761 if (sense->sense_key > 8) {
762 printk(" (INVALID)\n");
763 return;
764 }
765
766 printk(" (%s)\n", info[sense->sense_key]);
767} 765}
768 766
769/* 767/*
@@ -943,7 +941,7 @@ static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_que
943 set_bit(PACKET_MERGE_SEGS, &pd->flags); 941 set_bit(PACKET_MERGE_SEGS, &pd->flags);
944 return 0; 942 return 0;
945 } else { 943 } else {
946 printk(DRIVER_NAME": cdrom max_phys_segments too small\n"); 944 pr_err("cdrom max_phys_segments too small\n");
947 return -EIO; 945 return -EIO;
948 } 946 }
949} 947}
@@ -1563,9 +1561,10 @@ work_to_do:
1563 1561
1564static void pkt_print_settings(struct pktcdvd_device *pd) 1562static void pkt_print_settings(struct pktcdvd_device *pd)
1565{ 1563{
1566 printk(DRIVER_NAME": %s packets, ", pd->settings.fp ? "Fixed" : "Variable"); 1564 pr_info("%s packets, %u blocks, Mode-%c disc\n",
1567 printk("%u blocks, ", pd->settings.size >> 2); 1565 pd->settings.fp ? "Fixed" : "Variable",
1568 printk("Mode-%c disc\n", pd->settings.block_mode == 8 ? '1' : '2'); 1566 pd->settings.size >> 2,
1567 pd->settings.block_mode == 8 ? '1' : '2');
1569} 1568}
1570 1569
1571static int pkt_mode_sense(struct pktcdvd_device *pd, struct packet_command *cgc, int page_code, int page_control) 1570static int pkt_mode_sense(struct pktcdvd_device *pd, struct packet_command *cgc, int page_code, int page_control)
@@ -1749,7 +1748,7 @@ static noinline_for_stack int pkt_set_write_settings(struct pktcdvd_device *pd)
1749 /* 1748 /*
1750 * paranoia 1749 * paranoia
1751 */ 1750 */
1752 printk(DRIVER_NAME": write mode wrong %d\n", wp->data_block_type); 1751 pr_err("write mode wrong %d\n", wp->data_block_type);
1753 return 1; 1752 return 1;
1754 } 1753 }
1755 wp->packet_size = cpu_to_be32(pd->settings.size >> 2); 1754 wp->packet_size = cpu_to_be32(pd->settings.size >> 2);
@@ -1793,7 +1792,7 @@ static int pkt_writable_track(struct pktcdvd_device *pd, track_information *ti)
1793 if (ti->rt == 1 && ti->blank == 0) 1792 if (ti->rt == 1 && ti->blank == 0)
1794 return 1; 1793 return 1;
1795 1794
1796 printk(DRIVER_NAME": bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet); 1795 pr_err("bad state %d-%d-%d\n", ti->rt, ti->blank, ti->packet);
1797 return 0; 1796 return 0;
1798} 1797}
1799 1798
@@ -1820,22 +1819,22 @@ static int pkt_writable_disc(struct pktcdvd_device *pd, disc_information *di)
1820 * but i'm not sure, should we leave this to user apps? probably. 1819 * but i'm not sure, should we leave this to user apps? probably.
1821 */ 1820 */
1822 if (di->disc_type == 0xff) { 1821 if (di->disc_type == 0xff) {
1823 printk(DRIVER_NAME": Unknown disc. No track?\n"); 1822 pr_notice("unknown disc - no track?\n");
1824 return 0; 1823 return 0;
1825 } 1824 }
1826 1825
1827 if (di->disc_type != 0x20 && di->disc_type != 0) { 1826 if (di->disc_type != 0x20 && di->disc_type != 0) {
1828 printk(DRIVER_NAME": Wrong disc type (%x)\n", di->disc_type); 1827 pr_err("wrong disc type (%x)\n", di->disc_type);
1829 return 0; 1828 return 0;
1830 } 1829 }
1831 1830
1832 if (di->erasable == 0) { 1831 if (di->erasable == 0) {
1833 printk(DRIVER_NAME": Disc not erasable\n"); 1832 pr_notice("disc not erasable\n");
1834 return 0; 1833 return 0;
1835 } 1834 }
1836 1835
1837 if (di->border_status == PACKET_SESSION_RESERVED) { 1836 if (di->border_status == PACKET_SESSION_RESERVED) {
1838 printk(DRIVER_NAME": Can't write to last track (reserved)\n"); 1837 pr_err("can't write to last track (reserved)\n");
1839 return 0; 1838 return 0;
1840 } 1839 }
1841 1840
@@ -1860,7 +1859,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
1860 memset(&ti, 0, sizeof(track_information)); 1859 memset(&ti, 0, sizeof(track_information));
1861 1860
1862 if ((ret = pkt_get_disc_info(pd, &di))) { 1861 if ((ret = pkt_get_disc_info(pd, &di))) {
1863 printk("failed get_disc\n"); 1862 pr_err("failed get_disc\n");
1864 return ret; 1863 return ret;
1865 } 1864 }
1866 1865
@@ -1871,12 +1870,12 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
1871 1870
1872 track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */ 1871 track = 1; /* (di.last_track_msb << 8) | di.last_track_lsb; */
1873 if ((ret = pkt_get_track_info(pd, track, 1, &ti))) { 1872 if ((ret = pkt_get_track_info(pd, track, 1, &ti))) {
1874 printk(DRIVER_NAME": failed get_track\n"); 1873 pr_err("failed get_track\n");
1875 return ret; 1874 return ret;
1876 } 1875 }
1877 1876
1878 if (!pkt_writable_track(pd, &ti)) { 1877 if (!pkt_writable_track(pd, &ti)) {
1879 printk(DRIVER_NAME": can't write to this track\n"); 1878 pr_err("can't write to this track\n");
1880 return -EROFS; 1879 return -EROFS;
1881 } 1880 }
1882 1881
@@ -1886,11 +1885,11 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
1886 */ 1885 */
1887 pd->settings.size = be32_to_cpu(ti.fixed_packet_size) << 2; 1886 pd->settings.size = be32_to_cpu(ti.fixed_packet_size) << 2;
1888 if (pd->settings.size == 0) { 1887 if (pd->settings.size == 0) {
1889 printk(DRIVER_NAME": detected zero packet size!\n"); 1888 pr_notice("detected zero packet size!\n");
1890 return -ENXIO; 1889 return -ENXIO;
1891 } 1890 }
1892 if (pd->settings.size > PACKET_MAX_SECTORS) { 1891 if (pd->settings.size > PACKET_MAX_SECTORS) {
1893 printk(DRIVER_NAME": packet size is too big\n"); 1892 pr_err("packet size is too big\n");
1894 return -EROFS; 1893 return -EROFS;
1895 } 1894 }
1896 pd->settings.fp = ti.fp; 1895 pd->settings.fp = ti.fp;
@@ -1932,7 +1931,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
1932 pd->settings.block_mode = PACKET_BLOCK_MODE2; 1931 pd->settings.block_mode = PACKET_BLOCK_MODE2;
1933 break; 1932 break;
1934 default: 1933 default:
1935 printk(DRIVER_NAME": unknown data mode\n"); 1934 pr_err("unknown data mode\n");
1936 return -EROFS; 1935 return -EROFS;
1937 } 1936 }
1938 return 0; 1937 return 0;
@@ -1966,10 +1965,10 @@ static noinline_for_stack int pkt_write_caching(struct pktcdvd_device *pd,
1966 cgc.buflen = cgc.cmd[8] = 2 + ((buf[0] << 8) | (buf[1] & 0xff)); 1965 cgc.buflen = cgc.cmd[8] = 2 + ((buf[0] << 8) | (buf[1] & 0xff));
1967 ret = pkt_mode_select(pd, &cgc); 1966 ret = pkt_mode_select(pd, &cgc);
1968 if (ret) { 1967 if (ret) {
1969 printk(DRIVER_NAME": write caching control failed\n"); 1968 pr_err("write caching control failed\n");
1970 pkt_dump_sense(&cgc); 1969 pkt_dump_sense(&cgc);
1971 } else if (!ret && set) 1970 } else if (!ret && set)
1972 printk(DRIVER_NAME": enabled write caching on %s\n", pd->name); 1971 pr_notice("enabled write caching on %s\n", pd->name);
1973 return ret; 1972 return ret;
1974} 1973}
1975 1974
@@ -2084,11 +2083,11 @@ static noinline_for_stack int pkt_media_speed(struct pktcdvd_device *pd,
2084 } 2083 }
2085 2084
2086 if (!(buf[6] & 0x40)) { 2085 if (!(buf[6] & 0x40)) {
2087 printk(DRIVER_NAME": Disc type is not CD-RW\n"); 2086 pr_notice("disc type is not CD-RW\n");
2088 return 1; 2087 return 1;
2089 } 2088 }
2090 if (!(buf[6] & 0x4)) { 2089 if (!(buf[6] & 0x4)) {
2091 printk(DRIVER_NAME": A1 values on media are not valid, maybe not CDRW?\n"); 2090 pr_notice("A1 values on media are not valid, maybe not CDRW?\n");
2092 return 1; 2091 return 1;
2093 } 2092 }
2094 2093
@@ -2108,14 +2107,14 @@ static noinline_for_stack int pkt_media_speed(struct pktcdvd_device *pd,
2108 *speed = us_clv_to_speed[sp]; 2107 *speed = us_clv_to_speed[sp];
2109 break; 2108 break;
2110 default: 2109 default:
2111 printk(DRIVER_NAME": Unknown disc sub-type %d\n",st); 2110 pr_notice("unknown disc sub-type %d\n", st);
2112 return 1; 2111 return 1;
2113 } 2112 }
2114 if (*speed) { 2113 if (*speed) {
2115 printk(DRIVER_NAME": Max. media speed: %d\n",*speed); 2114 pr_info("maximum media speed: %d\n", *speed);
2116 return 0; 2115 return 0;
2117 } else { 2116 } else {
2118 printk(DRIVER_NAME": Unknown speed %d for sub-type %d\n",sp,st); 2117 pr_notice("unknown speed %d for sub-type %d\n", sp, st);
2119 return 1; 2118 return 1;
2120 } 2119 }
2121} 2120}
@@ -2205,7 +2204,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
2205 goto out; 2204 goto out;
2206 2205
2207 if ((ret = pkt_get_last_written(pd, &lba))) { 2206 if ((ret = pkt_get_last_written(pd, &lba))) {
2208 printk(DRIVER_NAME": pkt_get_last_written failed\n"); 2207 pr_err("pkt_get_last_written failed\n");
2209 goto out_putdev; 2208 goto out_putdev;
2210 } 2209 }
2211 2210
@@ -2235,11 +2234,11 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
2235 2234
2236 if (write) { 2235 if (write) {
2237 if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) { 2236 if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) {
2238 printk(DRIVER_NAME": not enough memory for buffers\n"); 2237 pr_err("not enough memory for buffers\n");
2239 ret = -ENOMEM; 2238 ret = -ENOMEM;
2240 goto out_putdev; 2239 goto out_putdev;
2241 } 2240 }
2242 printk(DRIVER_NAME": %lukB available on disc\n", lba << 1); 2241 pr_info("%lukB available on disc\n", lba << 1);
2243 } 2242 }
2244 2243
2245 return 0; 2244 return 0;
@@ -2360,7 +2359,8 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
2360 2359
2361 pd = q->queuedata; 2360 pd = q->queuedata;
2362 if (!pd) { 2361 if (!pd) {
2363 printk(DRIVER_NAME": %s incorrect request queue\n", bdevname(bio->bi_bdev, b)); 2362 pr_err("%s incorrect request queue\n",
2363 bdevname(bio->bi_bdev, b));
2364 goto end_io; 2364 goto end_io;
2365 } 2365 }
2366 2366
@@ -2382,13 +2382,13 @@ static void pkt_make_request(struct request_queue *q, struct bio *bio)
2382 } 2382 }
2383 2383
2384 if (!test_bit(PACKET_WRITABLE, &pd->flags)) { 2384 if (!test_bit(PACKET_WRITABLE, &pd->flags)) {
2385 printk(DRIVER_NAME": WRITE for ro device %s (%llu)\n", 2385 pr_notice("WRITE for ro device %s (%llu)\n",
2386 pd->name, (unsigned long long)bio->bi_sector); 2386 pd->name, (unsigned long long)bio->bi_sector);
2387 goto end_io; 2387 goto end_io;
2388 } 2388 }
2389 2389
2390 if (!bio->bi_size || (bio->bi_size % CD_FRAMESIZE)) { 2390 if (!bio->bi_size || (bio->bi_size % CD_FRAMESIZE)) {
2391 printk(DRIVER_NAME": wrong bio size\n"); 2391 pr_err("wrong bio size\n");
2392 goto end_io; 2392 goto end_io;
2393 } 2393 }
2394 2394
@@ -2609,7 +2609,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
2609 struct block_device *bdev; 2609 struct block_device *bdev;
2610 2610
2611 if (pd->pkt_dev == dev) { 2611 if (pd->pkt_dev == dev) {
2612 printk(DRIVER_NAME": Recursive setup not allowed\n"); 2612 pr_err("recursive setup not allowed\n");
2613 return -EBUSY; 2613 return -EBUSY;
2614 } 2614 }
2615 for (i = 0; i < MAX_WRITERS; i++) { 2615 for (i = 0; i < MAX_WRITERS; i++) {
@@ -2617,11 +2617,11 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
2617 if (!pd2) 2617 if (!pd2)
2618 continue; 2618 continue;
2619 if (pd2->bdev->bd_dev == dev) { 2619 if (pd2->bdev->bd_dev == dev) {
2620 printk(DRIVER_NAME": %s already setup\n", bdevname(pd2->bdev, b)); 2620 pr_err("%s already setup\n", bdevname(pd2->bdev, b));
2621 return -EBUSY; 2621 return -EBUSY;
2622 } 2622 }
2623 if (pd2->pkt_dev == dev) { 2623 if (pd2->pkt_dev == dev) {
2624 printk(DRIVER_NAME": Can't chain pktcdvd devices\n"); 2624 pr_err("can't chain pktcdvd devices\n");
2625 return -EBUSY; 2625 return -EBUSY;
2626 } 2626 }
2627 } 2627 }
@@ -2644,7 +2644,7 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
2644 atomic_set(&pd->cdrw.pending_bios, 0); 2644 atomic_set(&pd->cdrw.pending_bios, 0);
2645 pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name); 2645 pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name);
2646 if (IS_ERR(pd->cdrw.thread)) { 2646 if (IS_ERR(pd->cdrw.thread)) {
2647 printk(DRIVER_NAME": can't start kernel thread\n"); 2647 pr_err("can't start kernel thread\n");
2648 ret = -ENOMEM; 2648 ret = -ENOMEM;
2649 goto out_mem; 2649 goto out_mem;
2650 } 2650 }
@@ -2743,7 +2743,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev)
2743 if (!pkt_devs[idx]) 2743 if (!pkt_devs[idx])
2744 break; 2744 break;
2745 if (idx == MAX_WRITERS) { 2745 if (idx == MAX_WRITERS) {
2746 printk(DRIVER_NAME": max %d writers supported\n", MAX_WRITERS); 2746 pr_err("max %d writers supported\n", MAX_WRITERS);
2747 ret = -EBUSY; 2747 ret = -EBUSY;
2748 goto out_mutex; 2748 goto out_mutex;
2749 } 2749 }
@@ -2818,7 +2818,7 @@ out_mem:
2818 kfree(pd); 2818 kfree(pd);
2819out_mutex: 2819out_mutex:
2820 mutex_unlock(&ctl_mutex); 2820 mutex_unlock(&ctl_mutex);
2821 printk(DRIVER_NAME": setup of pktcdvd device failed\n"); 2821 pr_err("setup of pktcdvd device failed\n");
2822 return ret; 2822 return ret;
2823} 2823}
2824 2824
@@ -2969,7 +2969,7 @@ static int __init pkt_init(void)
2969 2969
2970 ret = register_blkdev(pktdev_major, DRIVER_NAME); 2970 ret = register_blkdev(pktdev_major, DRIVER_NAME);
2971 if (ret < 0) { 2971 if (ret < 0) {
2972 printk(DRIVER_NAME": Unable to register block device\n"); 2972 pr_err("unable to register block device\n");
2973 goto out2; 2973 goto out2;
2974 } 2974 }
2975 if (!pktdev_major) 2975 if (!pktdev_major)
@@ -2983,7 +2983,7 @@ static int __init pkt_init(void)
2983 2983
2984 ret = misc_register(&pkt_misc); 2984 ret = misc_register(&pkt_misc);
2985 if (ret) { 2985 if (ret) {
2986 printk(DRIVER_NAME": Unable to register misc device\n"); 2986 pr_err("unable to register misc device\n");
2987 goto out_misc; 2987 goto out_misc;
2988 } 2988 }
2989 2989