Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp636737pxb; Wed, 3 Nov 2021 09:49:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc/YbcHXwQApDd0PLHBlbqBtj5wyskcYw/AyOlY9b86qDJUdKh5wEvdgLwzWERMHM1hIBR X-Received: by 2002:a17:907:8a0d:: with SMTP id sc13mr45518925ejc.419.1635958199461; Wed, 03 Nov 2021 09:49:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1635958199; cv=pass; d=google.com; s=arc-20160816; b=mntEh+cBzOtI2sE99Zwb4qFh8eEjsEAMcfju+ZwvxlREe/rPvzgi+YXrfdzTLgv6cO k6boSQlgsxlIRZipS3ye9aaoX/USWVak2Gn7coTB9Uf/X4tOY13Mg25a4Vn9vTfXIa8Y LtolcZQQhd1nZzJdbFb8Iz7MBrBD+ZrwWzSuWlszFlXbafNO7Y96uHs0O2MQBcph4xjZ H+k12jzf5YdfWYdVUBf5cjErbwsjPAeU/xu1L3kl0QQqSGJvEw39RKiOU9CDfsB+mbV2 oHExj8MurzrXWzSA/f53QSGPV+iXVHO9LWLqV38s8MwT2usiHHzxrdSMhL6dtccc2Vv+ 54lQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:subject:from:references:cc:to:content-language :user-agent:date:message-id:dkim-signature; bh=vklV71tQz+gYe/2660xpWIGZqlkS7j/kAPZRX/cQH18=; b=SuwOgxAwM4yR6zRv1WhbAjBauR/n1f24cAGM8H3fntUPGt/H5VhyIYt1+yYLcuj/G+ WAE4icYtZarNKYf5dwECZKnJkTJiY7pbPAsHh9mEfODlvcZLI0oDr1nUgrYkByfgdYZn bWxAnwNIKmS3RTkhS83MK+ZgfQKmOoamdiKNKV59piOZzRd27l/wAqSKfLs2bl0SDBUX juEMM1eHRk3RAuE9OiheJ4U85/P97C7b3i/atwyZWLJiPQsstq+NqiiRXrOjot6Tf8K4 lVyo2EnLaRJUDOH09MllApeeA93/d7n4uAMSIUfuMnGFoa2NXoeOcGHJsBJj0FDmgXe7 +Gjw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=mimecast20200619 header.b="PCHPa/NX"; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do16si5683243ejc.357.2021.11.03.09.49.34; Wed, 03 Nov 2021 09:49:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@suse.com header.s=mimecast20200619 header.b="PCHPa/NX"; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232949AbhKCQuU (ORCPT + 99 others); Wed, 3 Nov 2021 12:50:20 -0400 Received: from de-smtp-delivery-102.mimecast.com ([194.104.109.102]:59618 "EHLO de-smtp-delivery-102.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbhKCQuT (ORCPT ); Wed, 3 Nov 2021 12:50:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1635958062; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vklV71tQz+gYe/2660xpWIGZqlkS7j/kAPZRX/cQH18=; b=PCHPa/NXrcIJSzRuX2FH7LkkdbwSZk5vPudYnnPiiU6iI3OgP9od6VmiBpLrneLHM/WDQP 3XAJVQHzVATThtIl+JDVowDvsWjBZToBoJrtNpwgccCM807/tWPaDrbFvAdoQNOxdrsiaf 2TgXUBZNY7/p6enPu4r93QCu7t6O388= Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2113.outbound.protection.outlook.com [104.47.17.113]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-39-XQA62fuuObmEMqIDJrAlRw-1; Wed, 03 Nov 2021 17:47:41 +0100 X-MC-Unique: XQA62fuuObmEMqIDJrAlRw-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FtSnhoszhOpPFursL+kFDY2K0SrUD8C3o/wS6hXP6KLRbKJCk69FFKF/KyOcBt//Acy2MkRkR6aq56t4nujgNzKTgdBrwCrx5on8nVgMd8C3yldLn8+AzwixIbwmdypn6zXURs4vQUhihbn+hLXhX44nfOEgGuhK5/1nshKbf7DvvgFTCwb8hfqUvAESt9ddnpD4FbGAWVctJfz5yc3zJwacwyT4BCryb9ve+TZyjNvbdHk4yPdJGMKF3HZesKZtBqcqnDAOkT0sHBhVqnJ/FzxShIY1eSJLrLY64Qf5t8qbZB32xq11/MX3A9jw1UocCRbTk43IfjhNx+ab6QT23A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vklV71tQz+gYe/2660xpWIGZqlkS7j/kAPZRX/cQH18=; b=GWgAkX1rZjB/TJB03g0y87pz2BRJzJtmGLDtBpHETdLeuoVGkEzRkSPadePChfKNp3OAnGL3p8hm0kM0VZKc0DTm4/e+INQ8UkX0J4LUsys5AHBVnqLJjfnOrHGqijo2Jj7Xw5otAKM6sXtx43vrU/xs5PFvDaA4uUkXNRZHar3xCJM/kNcD2N+bd4UgSVDSw5gBE5Ec8Rm5LlsisZabjM7nIZxeRrWG3xDqhA3i6C/dmui4sOmuYJ3k4Z6Pn1ltz904PJEuObsm+jGAms/PGIgUlM9Tq0E+D1yLE4K3tbVo0CzDbMYMmHCpNzLh7Vc8SFCh97/FEVNxcODRxFILVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from AM6PR04MB5366.eurprd04.prod.outlook.com (2603:10a6:20b:9d::19) by AS8PR04MB8119.eurprd04.prod.outlook.com (2603:10a6:20b:3f9::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Wed, 3 Nov 2021 16:47:39 +0000 Received: from AM6PR04MB5366.eurprd04.prod.outlook.com ([fe80::b81e:116f:90fa:1b9c]) by AM6PR04MB5366.eurprd04.prod.outlook.com ([fe80::b81e:116f:90fa:1b9c%3]) with mapi id 15.20.4669.011; Wed, 3 Nov 2021 16:47:39 +0000 Message-ID: <704e71ce-e6c6-6492-8f20-47e4fad8cc39@suse.com> Date: Wed, 3 Nov 2021 17:47:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Content-Language: en-US To: Charles Mirabile , linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Serge Schneider , Stefan Wahren , Nicolas Saenz Julienne , linux-rpi-kernel@lists.infradead.org, fedora-rpi@googlegroups.com, Mwesigwa Guma , Joel Savitz References: <20211029215516.801593-1-cmirabil@redhat.com> <20211029215516.801593-4-cmirabil@redhat.com> From: Matthias Brugger Subject: Re: [PATCH 3/5] drivers/auxdisplay: senshat: Raspberry Pi Sense HAT display driver In-Reply-To: <20211029215516.801593-4-cmirabil@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM7PR03CA0009.eurprd03.prod.outlook.com (2603:10a6:20b:130::19) To AM6PR04MB5366.eurprd04.prod.outlook.com (2603:10a6:20b:9d::19) MIME-Version: 1.0 Received: from [192.168.0.18] (188.86.219.160) by AM7PR03CA0009.eurprd03.prod.outlook.com (2603:10a6:20b:130::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 3 Nov 2021 16:47:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 74b98c14-aa96-463e-919c-08d99ee9a5ce X-MS-TrafficTypeDiagnostic: AS8PR04MB8119: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UKIgp1r/G6AaTMiXYtot8pgAG3+4qneVtkr9CwuCvvLSNzhV3YY076c9JWmCeOis5I0Si+6WQ3Z6LsOqgcUodS3UOsX8XpAqx4AUsq34l8gzt4umP8zVe0aQNq29Vurb5mRtwTm+Jssxn0SJJpZii50UVYuuOejqQfHQ7qFlXvvb6HrEErsQ91qtC8x4Kc+xXb513GHxe+9UBaSnzXuf2bWR6Bv2omWgk/+gQUdbxGdt40nW36SdbVWdJLpqdLHDE5f5VSR+ThY+NKXpHnZuJ2dOZ+O7V/ki3RR/i0D3n2m+BU93Ky/DvWHgdZNZkHZT7SzHYT2bnGvQeLuSjTNhgiLuTFitJ3ezfdpL9coLblnx0e0OIKYdDu/IWHNvip3ewpVntbToGkoXAgbaRq0WPGP9Hmciq9xdlgXCy5PSKYqJ2fLdlKZBS4QpYT7QGNu8enjMTVlAdRril+Dpx3P3k9H9E2qHBt+VdZGA4CDhyXkyzcS0kgYZimSfeiugGvAcxNJ+B4S8rvMrJCSLMUcCqFf6Dei9Chl1rCefI/ZOeqCGJGLU1XS8slzvE6cxFNFMcnq9dhEzuHg72rj8u58ypmfpy6PHsXnpvnltqAdDLuLi/vy5GMwY8w3xt9wm0Tg1j0CfD2csRpwGijZaT8+KikDNzsOQ3VMzLanTclnoyfUTugHkRTJb9E+Gj5VV4uR8P5zuwpggfSYOghAwXxsyhwCQNm2axkzIFAN7lkwsucs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5366.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(316002)(186003)(31696002)(66556008)(86362001)(83380400001)(54906003)(53546011)(16576012)(36756003)(55236004)(2906002)(7416002)(66476007)(26005)(38100700002)(8676002)(66946007)(5660300002)(31686004)(8936002)(6486002)(2616005)(4326008)(956004)(508600001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?M25tOW1nSnlHSk5HSVVIR1ltN3pwd25yUEpsajduMWR4TnVNdnJWRkx3L1ZC?= =?utf-8?B?UU81d0RYaTdoM1FLbTNaRzFkOExSbk8wZmYva1FKVFBVTUdnenpaeW5Obk0z?= =?utf-8?B?WDhzRVpFdVd1ZWR0akkwOU1TV01YalVYYzdaL0ZEZHpicHpWM1M3eVlaMUR6?= =?utf-8?B?b2VhalJHNWk0RW0zYjlJQU5qL1kyWW9INWRPKzNsWVNEam1vb0FIU3lpTGk0?= =?utf-8?B?UEV1TVpKMm9IcWYrbS9WYnp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FE?= =?utf-8?B?ZFJmc3BBRDY4V1pQVnhwNEJPMzVOMUVZYjB5N2tkbUErR3EyeTcxUTRyY3Fq?= =?utf-8?B?a0o5WCtmSnZ5ZWJEMUtzOTE5Y3NNUFE4SnFRVzZpNWI4cGVldTFmcVNPUmpB?= =?utf-8?Q?oavjLQjmhVNbljyRgpp++NI=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74b98c14-aa96-463e-919c-08d99ee9a5ce X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5366.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2021 16:47:39.6642 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EEkYWOdAU17rADuOkKUvrYnUs4E2350FVh75o/aAzaGmhJBK47uZQq0kM4MMbEnHEZ9iBlaLjjRJrj34QeuSZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8119 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/10/2021 23:55, Charles Mirabile wrote: > This patch implements control of the 8x8 RGB LED matrix display. > > Signed-off-by: Charles Mirabile > Signed-off-by: Mwesigwa Guma > Signed-off-by: Joel Savitz > --- > drivers/auxdisplay/Kconfig | 7 + > drivers/auxdisplay/Makefile | 1 + > drivers/auxdisplay/sensehat-display.c | 258 ++++++++++++++++++++++++++ > 3 files changed, 266 insertions(+) > create mode 100644 drivers/auxdisplay/sensehat-display.c > [....] > diff --git a/drivers/auxdisplay/sensehat-display.c b/drivers/auxdisplay/sensehat-display.c > new file mode 100644 > index 000000000000..5980ad23fd4f > --- /dev/null > +++ b/drivers/auxdisplay/sensehat-display.c [...] > + > +static ssize_t > +sensehat_display_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) > +{ > + struct sensehat *sensehat = container_of(filp->private_data, struct sensehat, display.mdev); > + struct sensehat_display *sensehat_display = &sensehat->display; > + u8 temp[VMEM_SIZE]; > + > + if (*f_pos >= VMEM_SIZE) > + return -EFBIG; > + if (*f_pos + count > VMEM_SIZE) > + count = VMEM_SIZE - *f_pos; > + if (copy_from_user(temp, buf, count)) > + return -EFAULT; > + if (mutex_lock_interruptible(&sensehat_display->rw_mtx)) > + return -ERESTARTSYS; > + memcpy(sensehat_display->vmem + *f_pos, temp, count); So we copy from buf into temp, from temp into vmem and then we 'transform' vmem into the representation of pixel_data. As you are implementing the user-space interface, couldn't we just change the pixel representation there and get rid of the transformation? > + sensehat_update_display(sensehat); > + *f_pos += count; > + mutex_unlock(&sensehat_display->rw_mtx); > + return count; > +} > + > +static long sensehat_display_ioctl(struct file *filp, unsigned int cmd, > + unsigned long arg) > +{ > + struct sensehat *sensehat = container_of(filp->private_data, struct sensehat, display.mdev); > + struct sensehat_display *sensehat_display = &sensehat->display; > + void __user *user_ptr = (void __user *)arg; > + u8 temp[GAMMA_SIZE]; > + int ret; > + > + if (mutex_lock_interruptible(&sensehat_display->rw_mtx)) > + return -ERESTARTSYS; > + switch (cmd) { > + case SENSEDISP_IOGET_GAMMA: > + if (copy_to_user(user_ptr, sensehat_display->gamma, GAMMA_SIZE)) { > + ret = -EFAULT; > + goto out_unlock; > + } > + ret = 0; > + goto out_unlock; > + case SENSEDISP_IOSET_GAMMA: > + if (copy_from_user(temp, user_ptr, GAMMA_SIZE)) { > + ret = -EFAULT; > + goto out_unlock; > + } > + ret = 0; > + goto out_update; That's just a 'break;' correct? Regards, Matthias