Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1068535ybl; Tue, 13 Aug 2019 06:59:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiB2NH9obs5BKWVrGLYeGBHx8BuvuS5735/PFuD85f0lvCHW8uBh42Ml2qMqqcKWVLfs/d X-Received: by 2002:a17:90a:dc82:: with SMTP id j2mr2412405pjv.89.1565704749099; Tue, 13 Aug 2019 06:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565704749; cv=none; d=google.com; s=arc-20160816; b=jPmpS+aFHB6aHohl9WZ0ldqoAY1S07jrMiJxp5oMP7xXkGOwA467ZHz8znfklushrA ogO+9Osc6KwYVevLGVPt9Y3ALZFotXhtLZZjWMYU+LFwquHfTS4hXDgDm5QQWyzygDXd /RIk7kGHglQo9IMOiQsPe3kDrmJtHE9+kAImj+ixAgBHRM6WervJYp0H7DezmWfTzRnC U81pV9RQWaBydMxG0ZJx0E7GCR2HHUHHWTRw9kDktn5hkXkJ6txIejbswJaJi2mdXiHv Q60vrFchGIrcZQH+7vnfAej6vl10FS1OwZTj/kpwI/q3wNpu7drnamRm+fJtvyRZ8082 /m/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=UPqVMYRKgPny4jLiI9xhCyK5fHo3cjEgQkb61xfTW14=; b=P7TEE8NRVzF6l32OaFfWcTUFISh+2h4l8jl1pZRM9G+LblceFfDKt1+JwjpiwqN7SL +oofLA6bzPihdcPZ+bgglu+s25O7mY7eYQqrGtrvDj6oygZ01dW+/PsAPm3Yssnknq4/ 0dbpno+/N3v9RPgZPGnsZgCL4GDoBthLpJC15R4KJbtDGKxgLCxUH+pwaVw6XEO7wlsR ePHijzfbAqpxF3Zi0G0l3ACnJjJIvAgTBkyGvka1SYjcvt69WbKjoNx6h/cg0CvtBKKr ct1Zc/ZKrw5VVYTe9oMjJuUFhSQg01iixpzgjZq+3VqEEHztI1i4B4F5/AzarpvuBufX jT6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a186si62384267pge.365.2019.08.13.06.58.52; Tue, 13 Aug 2019 06:59:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729263AbfHMN6S (ORCPT + 99 others); Tue, 13 Aug 2019 09:58:18 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:33175 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727427AbfHMN6S (ORCPT ); Tue, 13 Aug 2019 09:58:18 -0400 Received: by mail-qt1-f193.google.com with SMTP id v38so14010887qtb.0 for ; Tue, 13 Aug 2019 06:58:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UPqVMYRKgPny4jLiI9xhCyK5fHo3cjEgQkb61xfTW14=; b=Ht/wlkQ3/o7iL/GMhB7+8huXacIDzH6/udFZQ/tuB6daV1LqAt6+UyB5aEPHl1M1fy zYE3Xf3qfo4kK6n/Ml3RsncFshlE9HIg+Kaju6MKxcFK8y+gRmh3oJ4045zz6jhLpl7e vs1Gzi6+CtMRhsa6R5cNCaoKmksiFG83CMT8A1Q6GKZBsbzfbgGR8hGCt1INOiVwICLH 54+UhFkbDzCED8W+APXwN5IEsM+LT00YT45h9ZjnOrAQvcCz0UmJqTrxHiRiGEeIPyXF +IXkNw7nnuhLLT5TeB8Elqnw2zxhDlTF8Mc0Vmab+g20sjhaRsRW23SLekhm4vigRJvC /qIA== X-Gm-Message-State: APjAAAVoTyv/Es6fIFAYghTb51fsv3Z05nZXwLpjMOjS+dUbyP3A5baI oklH69ENBFwj5mlUeBdCprFxMnfE4obZtOOtokVnIA== X-Received: by 2002:ac8:33c7:: with SMTP id d7mr20342902qtb.294.1565704696825; Tue, 13 Aug 2019 06:58:16 -0700 (PDT) MIME-Version: 1.0 References: <20190812162105.13428-1-benjamin.tissoires@redhat.com> In-Reply-To: From: Benjamin Tissoires Date: Tue, 13 Aug 2019 15:58:05 +0200 Message-ID: Subject: Re: [PATCH] HID: uhid: actually use the err number from userspace To: David Rheinsberg Cc: Jiri Kosina , "open list:HID CORE LAYER" , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 13, 2019 at 12:50 PM David Rheinsberg wrote: > > Hey > > On Mon, Aug 12, 2019 at 6:21 PM Benjamin Tissoires > wrote: > > > > This can help debugging the situation > > > > Signed-off-by: Benjamin Tissoires > > --- > > > > Hi, > > > > not entirely sure if we can use this in a such simple way. > > > > However, this is useful to mimic device behaviour from userspace. > > > > Cheers, > > Benjamin > > > > drivers/hid/uhid.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c > > index fa0cc0899827..2fa32e7fc733 100644 > > --- a/drivers/hid/uhid.c > > +++ b/drivers/hid/uhid.c > > @@ -284,7 +284,7 @@ static int uhid_hid_set_report(struct hid_device *hid, unsigned char rnum, > > goto unlock; > > > > if (uhid->report_buf.u.set_report_reply.err) > > - ret = -EIO; > > + ret = -uhid->report_buf.u.set_report_reply.err; > > I am generally in favor of this. But: > > 1) can you do this for both set_report *and* get_report? right :) > > 2) I think you have to filter some of the error codes. For instance, > if you return one of the -ERESTARTSYS codes, this might cause the > syscall to restart (if auto-restart is enabled on this context). At > the same time, this is not *that* bad. It might even be useful for the > userspace driver to trigger an EINTR. At least we should be aware of > this. So maybe filters are not necessary.. Mhhh. Comments? I haven't thought at all of the side effects of letting the user return a random error code. I have the impression that anything below EHWPOISON (133) is relatively safe. So maybe we should just make sure the error code is below 134? The ERESTARTSYS has a few warnings in the include file, so I guess the side effects might be too much for what we want to deal with. Cheers, Benjamin > > Thanks > David > > > else > > ret = count; > > > > -- > > 2.19.2 > >