Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: bcm2835-camera: Provide more specific probe error messages

Currently there is only a catch-all info message which print the
relevant error code without any context. So add more specific error
messages in order to narrow down possible issues.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Stefan Wahren and committed by
Greg Kroah-Hartman
9c85a4d0 b7491a9f

+39 -19
+39 -19
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
··· 1539 1539 struct vchiq_mmal_component *camera; 1540 1540 1541 1541 ret = vchiq_mmal_init(&dev->instance); 1542 - if (ret < 0) 1542 + if (ret < 0) { 1543 + v4l2_err(&dev->v4l2_dev, "%s: vchiq mmal init failed %d\n", 1544 + __func__, ret); 1543 1545 return ret; 1546 + } 1544 1547 1545 1548 /* get the camera component ready */ 1546 1549 ret = vchiq_mmal_component_init(dev->instance, "ril.camera", ··· 1552 1549 goto unreg_mmal; 1553 1550 1554 1551 camera = dev->component[MMAL_COMPONENT_CAMERA]; 1555 - if (camera->outputs < MMAL_CAMERA_PORT_COUNT) { 1552 + if (camera->outputs < MMAL_CAMERA_PORT_COUNT) { 1553 + v4l2_err(&dev->v4l2_dev, "%s: too few camera outputs %d needed %d\n", 1554 + __func__, camera->outputs, MMAL_CAMERA_PORT_COUNT); 1556 1555 ret = -EINVAL; 1557 1556 goto unreg_camera; 1558 1557 } ··· 1562 1557 ret = set_camera_parameters(dev->instance, 1563 1558 camera, 1564 1559 dev); 1565 - if (ret < 0) 1560 + if (ret < 0) { 1561 + v4l2_err(&dev->v4l2_dev, "%s: unable to set camera parameters: %d\n", 1562 + __func__, ret); 1566 1563 goto unreg_camera; 1564 + } 1567 1565 1568 1566 /* There was an error in the firmware that meant the camera component 1569 1567 * produced BGR instead of RGB. ··· 1655 1647 1656 1648 if (dev->component[MMAL_COMPONENT_PREVIEW]->inputs < 1) { 1657 1649 ret = -EINVAL; 1658 - pr_debug("too few input ports %d needed %d\n", 1659 - dev->component[MMAL_COMPONENT_PREVIEW]->inputs, 1); 1650 + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", 1651 + __func__, dev->component[MMAL_COMPONENT_PREVIEW]->inputs, 1); 1660 1652 goto unreg_preview; 1661 1653 } 1662 1654 ··· 1669 1661 1670 1662 if (dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs < 1) { 1671 1663 ret = -EINVAL; 1672 - v4l2_err(&dev->v4l2_dev, "too few input ports %d needed %d\n", 1673 - dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs, 1664 + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", 1665 + __func__, dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs, 1674 1666 1); 1675 1667 goto unreg_image_encoder; 1676 1668 } ··· 1684 1676 1685 1677 if (dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs < 1) { 1686 1678 ret = -EINVAL; 1687 - v4l2_err(&dev->v4l2_dev, "too few input ports %d needed %d\n", 1688 - dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs, 1679 + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", 1680 + __func__, dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs, 1689 1681 1); 1690 1682 goto unreg_vid_encoder; 1691 1683 } ··· 1714 1706 sizeof(enable)); 1715 1707 } 1716 1708 ret = bm2835_mmal_set_all_camera_controls(dev); 1717 - if (ret < 0) 1709 + if (ret < 0) { 1710 + v4l2_err(&dev->v4l2_dev, "%s: failed to set all camera controls: %d\n", 1711 + __func__, ret); 1718 1712 goto unreg_vid_encoder; 1713 + } 1719 1714 1720 1715 return 0; 1721 1716 ··· 1884 1873 snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), 1885 1874 "%s", BM2835_MMAL_MODULE_NAME); 1886 1875 ret = v4l2_device_register(NULL, &dev->v4l2_dev); 1887 - if (ret) 1876 + if (ret) { 1877 + dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", 1878 + __func__, ret); 1888 1879 goto free_dev; 1880 + } 1889 1881 1890 1882 /* setup v4l controls */ 1891 1883 ret = bm2835_mmal_init_controls(dev, &dev->ctrl_handler); 1892 - if (ret < 0) 1884 + if (ret < 0) { 1885 + v4l2_err(&dev->v4l2_dev, "%s: could not init controls: %d\n", 1886 + __func__, ret); 1893 1887 goto unreg_dev; 1888 + } 1894 1889 dev->v4l2_dev.ctrl_handler = &dev->ctrl_handler; 1895 1890 1896 1891 /* mmal init */ 1897 1892 dev->instance = instance; 1898 1893 ret = mmal_init(dev); 1899 - if (ret < 0) 1894 + if (ret < 0) { 1895 + v4l2_err(&dev->v4l2_dev, "%s: mmal init failed: %d\n", 1896 + __func__, ret); 1900 1897 goto unreg_dev; 1901 - 1898 + } 1902 1899 /* initialize queue */ 1903 1900 q = &dev->capture.vb_vidq; 1904 1901 memset(q, 0, sizeof(*q)); ··· 1924 1905 1925 1906 /* initialise video devices */ 1926 1907 ret = bm2835_mmal_init_device(dev, &dev->vdev); 1927 - if (ret < 0) 1908 + if (ret < 0) { 1909 + v4l2_err(&dev->v4l2_dev, "%s: could not init device: %d\n", 1910 + __func__, ret); 1928 1911 goto unreg_dev; 1912 + } 1929 1913 1930 1914 /* Really want to call vidioc_s_fmt_vid_cap with the default 1931 1915 * format, but currently the APIs don't join up. 1932 1916 */ 1933 1917 ret = mmal_setup_components(dev, &default_v4l2_format); 1934 1918 if (ret < 0) { 1935 - v4l2_err(&dev->v4l2_dev, 1936 - "%s: could not setup components\n", __func__); 1919 + v4l2_err(&dev->v4l2_dev, "%s: could not setup components: %d\n", 1920 + __func__, ret); 1937 1921 goto unreg_dev; 1938 1922 } 1939 1923 ··· 1960 1938 bcm2835_cleanup_instance(gdev[i]); 1961 1939 gdev[i] = NULL; 1962 1940 } 1963 - pr_info("%s: error %d while loading driver\n", 1964 - BM2835_MMAL_MODULE_NAME, ret); 1965 1941 1966 1942 cleanup_mmal: 1967 1943 vchiq_mmal_finalise(instance);