[{"id":1587,"web_url":"https://patchwork.libcamera.org/comment/1587/","msgid":"<20190511125707.GF4946@pendragon.ideasonboard.com>","date":"2019-05-11T12:57:07","subject":"Re: [libcamera-devel] [PATCH v3 07/11] libcamera: media_device:\n\tMake open() and close() private","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Sat, May 11, 2019 at 11:19:03AM +0200, Niklas Söderlund wrote:\n> All external callers to open() and close() have been refactored and\n> there is no need to expose these functions anymore, make them private.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/include/media_device.h |  6 +-\n>  src/libcamera/media_device.cpp       | 98 ++++++++++++++--------------\n>  2 files changed, 52 insertions(+), 52 deletions(-)\n> \n> diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h\n> index 883985055eb419dd..e513a2fee1b91a1b 100644\n> --- a/src/libcamera/include/media_device.h\n> +++ b/src/libcamera/include/media_device.h\n> @@ -30,9 +30,6 @@ public:\n>  \tvoid release();\n>  \tbool busy() const { return acquired_; }\n>  \n> -\tint open();\n> -\tvoid close();\n> -\n>  \tint populate();\n>  \tbool valid() const { return valid_; }\n>  \n> @@ -62,6 +59,9 @@ private:\n>  \tbool valid_;\n>  \tbool acquired_;\n>  \n> +\tint open();\n> +\tvoid close();\n> +\n>  \tstd::map<unsigned int, MediaObject *> objects_;\n>  \tMediaObject *object(unsigned int id);\n>  \tbool addObject(MediaObject *object);\n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index b1cc37e840a9fa9d..62c59e7e8fc0299f 100644\n> --- a/src/libcamera/media_device.cpp\n> +++ b/src/libcamera/media_device.cpp\n> @@ -126,55 +126,6 @@ void MediaDevice::release()\n>   * \\sa acquire(), release()\n>   */\n>  \n> -/**\n> - * \\brief Open the media device\n> - *\n> - * \\return 0 on success or a negative error code otherwise\n> - * \\retval -EBUSY Media device already open\n> - * \\sa close()\n> - */\n> -int MediaDevice::open()\n> -{\n> -\tif (fd_ != -1) {\n> -\t\tLOG(MediaDevice, Error) << \"MediaDevice already open\";\n> -\t\treturn -EBUSY;\n> -\t}\n> -\n> -\tint ret = ::open(deviceNode_.c_str(), O_RDWR);\n> -\tif (ret < 0) {\n> -\t\tret = -errno;\n> -\t\tLOG(MediaDevice, Error)\n> -\t\t\t<< \"Failed to open media device at \"\n> -\t\t\t<< deviceNode_ << \": \" << strerror(-ret);\n> -\t\treturn ret;\n> -\t}\n> -\tfd_ = ret;\n> -\n> -\treturn 0;\n> -}\n> -\n> -/**\n> - * \\brief Close the media device\n> - *\n> - * This function closes the media device node. It does not invalidate the media\n> - * graph and all cached media objects remain valid and can be accessed normally.\n> - * Once closed no operation interacting with the media device node can be\n> - * performed until the device is opened again.\n> - *\n> - * Closing an already closed device is allowed and will not perform any\n> - * operation.\n> - *\n> - * \\sa open()\n> - */\n> -void MediaDevice::close()\n> -{\n> -\tif (fd_ == -1)\n> -\t\treturn;\n> -\n> -\t::close(fd_);\n> -\tfd_ = -1;\n> -}\n> -\n>  /**\n>   * \\brief Populate the MediaDevice with device information and media objects\n>   *\n> @@ -440,6 +391,55 @@ int MediaDevice::disableLinks()\n>   * driver unloading for most devices. The media device is passed as a parameter.\n>   */\n>  \n> +/**\n> + * \\brief Open the media device\n> + *\n> + * \\return 0 on success or a negative error code otherwise\n> + * \\retval -EBUSY Media device already open\n> + * \\sa close()\n> + */\n> +int MediaDevice::open()\n> +{\n> +\tif (fd_ != -1) {\n> +\t\tLOG(MediaDevice, Error) << \"MediaDevice already open\";\n> +\t\treturn -EBUSY;\n> +\t}\n> +\n> +\tint ret = ::open(deviceNode_.c_str(), O_RDWR);\n> +\tif (ret < 0) {\n> +\t\tret = -errno;\n> +\t\tLOG(MediaDevice, Error)\n> +\t\t\t<< \"Failed to open media device at \"\n> +\t\t\t<< deviceNode_ << \": \" << strerror(-ret);\n> +\t\treturn ret;\n> +\t}\n> +\tfd_ = ret;\n> +\n> +\treturn 0;\n> +}\n> +\n> +/**\n> + * \\brief Close the media device\n> + *\n> + * This function closes the media device node. It does not invalidate the media\n> + * graph and all cached media objects remain valid and can be accessed normally.\n> + * Once closed no operation interacting with the media device node can be\n> + * performed until the device is opened again.\n> + *\n> + * Closing an already closed device is allowed and will not perform any\n> + * operation.\n> + *\n> + * \\sa open()\n> + */\n> +void MediaDevice::close()\n> +{\n> +\tif (fd_ == -1)\n> +\t\treturn;\n> +\n> +\t::close(fd_);\n> +\tfd_ = -1;\n> +}\n> +\n>  /**\n>   * \\var MediaDevice::objects_\n>   * \\brief Global map of media objects (entities, pads, links) keyed by their","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B75C60E4F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 11 May 2019 14:57:23 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 374B7D5;\n\tSat, 11 May 2019 14:57:23 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1557579443;\n\tbh=FOVSgRd4+joe1g9a0loVoK1LXkm0kgxfRv44/jE6zSA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=INUcplMZbwHrPjJCKmVoBcgdtRtdjSCWVRcKCaoENzG16LJ/Zf7WTwVoaA2HuMKAJ\n\tavRiutMkYlznrTxBrGfyK4BgUO6owzqnjKi45bJ3ew1GRSMyuRl2n0RZJHGY3cxXmX\n\taVrGyGNgDSgVSW0tdd2MDJrSxQ1T0icSH18K/CPE=","Date":"Sat, 11 May 2019 15:57:07 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190511125707.GF4946@pendragon.ideasonboard.com>","References":"<20190511091907.10050-1-niklas.soderlund@ragnatech.se>\n\t<20190511091907.10050-8-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190511091907.10050-8-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 07/11] libcamera: media_device:\n\tMake open() and close() private","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 11 May 2019 12:57:23 -0000"}}]