Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2782963pxb; Mon, 1 Nov 2021 01:33:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKSaIMJt8B7qGBFjIW/iSoNDaP2boCFY7n6sXGchveNIZ6pMo3oAZC0c+Y7JzsdLZdCjwh X-Received: by 2002:a17:906:8cd:: with SMTP id o13mr35756904eje.341.1635755630572; Mon, 01 Nov 2021 01:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635755630; cv=none; d=google.com; s=arc-20160816; b=XQyWkKaZzj63dDeHB5DqDLJEMnuBnJqKKFzuq5RNy30WFdYIorPEOGO1zePM5NzOWI np5y30b96z1GSz8wyfVOBQ1Gvl+Cn0VAR6rIx6t4Xd7mN3A1zzEg94LdALELhGZx+aSD yjptGtzSH6lZ73QDuskuDg8D3gNjak32SGzybm7hfBe59wWUD32pTAXh95eJiNj9TfkJ qfFvQ4jG7goZAMBo0Nu5URHxdvfH0DbZWGyoPasktMqQsJEi/XFKZfPKpdCdoMu6yGmh 2gKXmITmKxcmXoAv8J+bgfYfTOVkY7Tb8SJpJyJRBEEnmo22lOoxkR1Xb5s61R2YSc5G SqxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZybQDWvDppp1WvdV2Jpafbev6EV4+tR4aNWToS54UOc=; b=sz4iz1XKcPtVDExjNv5RqvNaFVGexY3CIgzkNWHr70nI0+9GdGVkgk/KdtPM/yvnv8 +Ht995I1RQvYw8sFR5VqXtZDIskc9ssaeQGpUdw+t1Dt7jjwhoXq/q4538jxfe+Tz6Pr 41DDVP6EcXbvxCDHeTs3fGV5xBeZwr5cBCdTPI6MyUIq9mpV8WGavYUs1TJpAjYrgSmx dvL8mJIXJ7iLXSUzbLSfs41LDUeQtKL3NnyeGSgzeZs3fCCIac1tdVaf9t7YC7ARnKGd sOwwjIhZq8OkIyUKn4oRV2ShH4YTDWaKMGr38Ejf0TTCkNwd30SxJCWnvDKSoA6VtpAB 6IhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dEZv0J8M; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qa41si5184893ejc.612.2021.11.01.01.33.24; Mon, 01 Nov 2021 01:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dEZv0J8M; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231386AbhKAIes (ORCPT + 99 others); Mon, 1 Nov 2021 04:34:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:49038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231371AbhKAIer (ORCPT ); Mon, 1 Nov 2021 04:34:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 61A17604DC; Mon, 1 Nov 2021 08:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635755534; bh=WWtJFKR4jTlASd9KJ+hLEAZFd4MaJ5istoeU4ycOG5A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dEZv0J8MokrWkjX8PYt6hu+hQ2AxLuqSMhDSiXl6/Oc97xUwbDD2ChOJkl+PTajFO 3h3V2esP3ydcX5seZfBFivkKgxoxrSndXyy5A9dIRfRpShfA6dCT7oo3TH7EFJSlfn koxFx2OyT5f1tdRl1FtSDd6jhxUteExXtsRG9i74= Date: Mon, 1 Nov 2021 09:32:12 +0100 From: Greg KH To: Zijun Hu Cc: robh@kernel.org, jirislaby@kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, Zijun Hu Subject: Re: [PATCH v1] serdev: Add interface serdev_device_ioctl Message-ID: References: <1635753048-5289-1-git-send-email-zijuhu@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Mon, Nov 01, 2021 at 04:29:10PM +0800, Zijun Hu wrote: > > > On 11/1/2021 3:59 PM, Greg KH wrote: > > On Mon, Nov 01, 2021 at 03:50:48PM +0800, Zijun Hu wrote: > >> From: Zijun Hu > >> > >> For serdev_device which is mounted at virtual tty port, tty ioctl() > >> maybe be used to make serdev_device ready to talk with tty port, so > >> add interface serdev_device_ioctl(). > >> > >> Signed-off-by: Zijun Hu > >> --- > >> drivers/tty/serdev/core.c | 11 +++++++++++ > >> drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ > >> include/linux/serdev.h | 9 +++++++++ > >> 3 files changed, 32 insertions(+) > >> > >> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c > >> index f1324fe99378..c0f6cd64716b 100644 > >> --- a/drivers/tty/serdev/core.c > >> +++ b/drivers/tty/serdev/core.c > >> @@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) > >> } > >> EXPORT_SYMBOL_GPL(serdev_device_set_tiocm); > >> > >> +int serdev_device_ioctl(struct serdev_device *serdev, unsigned int cmd, unsigned long arg) > >> +{ > >> + struct serdev_controller *ctrl = serdev->ctrl; > >> + > >> + if (!ctrl || !ctrl->ops->ioctl) > >> + return -EOPNOTSUPP; > > > > Wrong error for returning that an ioctl is not handled :( > checkpatch.pl always reports below WARNING when i use ENOTSUPP as present interfaces > do. so i change error code to EOPNOTSUPP. > > #28: FILE: drivers/tty/serdev/core.c:412: > + return -ENOTSUPP; > > WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP Both of them are not the correct error to return when an ioctl is not supported. > > Anyway, what in-tree driver needs this functionality? Why does serdev > > need any ioctl commands? > > > i am developing driver for a special bluetooth controller which is integrated within SOC, > and it does not connect with the BT HOST with UART as normal controller do, but it has very > similar features as the BT controller with UART I/F. it is mounted on a virtual serial port > driven by a tty driver developed. but it need to call tty ioctl to make the > special BT controller ready to talk with tty port. so i add this interface. Please submit this change when you submit your driver that uses it at the same time so we can review them all at once. We do not add apis that are not used in the kernel tree. > as you known, the main purpose of ioctl is to achieve MISC and irregular control. so it is useful > for these irregular devices. For tty devices, "custom" ioctls are not ok, use the standard tty commands and you should be fine for everything you need to do. If not, then perhaps your design is incorrect? thanks, greg k-h