Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3087408rwe; Mon, 29 Aug 2022 05:44:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR6+Kso/pKr9N+8iOh0Y9Wwc78+2sLm7d8W38P1CLS5szVFjZx6ZIWMB0vsn57lbfnImdUwr X-Received: by 2002:a17:902:ebc2:b0:172:94f7:1b5e with SMTP id p2-20020a170902ebc200b0017294f71b5emr16908485plg.131.1661777071949; Mon, 29 Aug 2022 05:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661777071; cv=none; d=google.com; s=arc-20160816; b=gIohhGiQyBVjA4+nwMjqBoxSNYIgvTYJ3vJRreYYhm9GpXaisQ/h0rzBNsdxLsb2PE 3Awxxwj+1fjK/GxVryzpfwm/tQImep5IfS7hDUborffWf6MdixQz2Qupxi6sXr4iAumf u9IDk17YUNpP6AQYCvkJ3zZO+dhdJ/aplTqm6hk19KIKUk7hPlQ5J2Muz9q67unL5clR mCcdAeOoup53Zz+HV01Jz3/qDi/Da7KWn2OOP8TTONnueXv/VK4aXj9XVOKvZCghAiTQ fUvh6ZD0a45VDfM6eQhAytMdAfn6NhIHcTE1JAUmG4qibwGcP47B9uEEUygSSbDiMip5 A1Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=hTnU5XJ9L43SHZ+Xq7Gi8R3gkUfJVM3lIj1Sd41JgoY=; b=IHWe2ViL9sBvCXonl9AzWK2Cnrtl4PZqac1sWJk+D1KzSs08LGHekaxer8BNTDc1vT 2fmDd0Xz2PbRmkFkn24XwnWfWxDhRoFUK7miRVGF/tRFGbo3/wyPqx+y3XeBJUilGX70 VxnifV/ibCq0b1FDai/rzbocXhCo07FlKceFZMbjV6FVucYngvh/Szgu2ODvDzEzbrok AbrCKveAGgBKy36SkwKjC+3g3Efe8TQa4swZYWu+PkKKbcF2pMU9wiSHGkWMze33gpjU kTnS4F/Rs5ADgbnj2IYc5Fmoa8NTLwAVV3gz2pQruL72ImKXWztqN7vGPpxnwHQcoLqM Cx3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c9n04zJX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j10-20020aa78dca000000b00537bb009bebsi8061630pfr.287.2022.08.29.05.44.21; Mon, 29 Aug 2022 05:44:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c9n04zJX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231550AbiH2M1O (ORCPT + 99 others); Mon, 29 Aug 2022 08:27:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbiH2M0m (ORCPT ); Mon, 29 Aug 2022 08:26:42 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F3B191D1A; Mon, 29 Aug 2022 05:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661775027; x=1693311027; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=oxQnpIC7Es3fbk5Y7KL1o+zPbw4eWKeljrhF6pZeVsU=; b=c9n04zJXK+ylVyxhfduX1T3vms3s2gxOxI0408bWObExuazE+SAa2Jg3 FFwzXdnNAlhynWoe7iGgJQ12tMKPG3+h4zCdiV+6u9HPR9nlofpBSEDge /kvUtoVRPLSn4QrAePZMy4IKsfuuTuF+Z4yMSZDiFrhGAumz8FT8IChR8 PFDAZphQrY7wBjQEzDxjHt7mOtp3ZMXlteIqRDCCBZBiuEY9BcArQ553I ImrvBevAP+JL5HNgWY2FoG9RQkQaZk8iI9nJYjfvkswQh5v+RQ5YMl04x rJLwI0aBos8nIyNiCNkItqNTLTZ2F1/Qj6C2mhhOSCTOEMuk8iefO3ENA A==; X-IronPort-AV: E=McAfee;i="6500,9779,10454"; a="294886252" X-IronPort-AV: E=Sophos;i="5.93,272,1654585200"; d="scan'208";a="294886252" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2022 05:09:15 -0700 X-IronPort-AV: E=Sophos;i="5.93,272,1654585200"; d="scan'208";a="588142891" Received: from kvehmane-mobl1.ger.corp.intel.com ([10.251.220.41]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2022 05:09:08 -0700 Date: Mon, 29 Aug 2022 15:09:09 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Andy Shevchenko cc: Greg Kroah-Hartman , Jiri Slaby , "open list:SERIAL DRIVERS" , Jonathan Corbet , Andy Shevchenko , Vladimir Zapolskiy , Russell King , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Maxime Coquelin , Alexandre Torgue , Linux Documentation List , Linux Kernel Mailing List , linux-arm Mailing List , linux-stm32@st-md-mailman.stormreply.com, Lino Sanfilippo Subject: Re: [PATCH 3/3] serial: Add kserial_rs485 to avoid wasted space due to .padding In-Reply-To: Message-ID: <1712a4c5-638-4e63-af29-32bdcbaab443@linux.intel.com> References: <20220826144629.11507-1-ilpo.jarvinen@linux.intel.com> <20220826144629.11507-4-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-174262208-1661774957=:1928" X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-174262208-1661774957=:1928 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Fri, 26 Aug 2022, Andy Shevchenko wrote: > On Fri, Aug 26, 2022 at 5:51 PM Ilpo Järvinen > wrote: > > > -static int user_rs485_to_kernel_serial_rs485(struct serial_rs485 *rs485, > > +static int user_rs485_to_kernel_serial_rs485(struct kserial_rs485 *rs485, > > const struct serial_rs485 __user *rs485_user) > > { > > - if (copy_from_user(rs485, rs485_user, sizeof(*rs485))) > > + struct serial_rs485 rs485_uapi; > > + > > + if (copy_from_user(&rs485_uapi, rs485_user, sizeof(*rs485))) > > return -EFAULT; > > > + *rs485 = *((struct kserial_rs485 *)&rs485_uapi); > > So with all assets we have we can be sure that on BE64 / BE32 machines > this will be flawless. Is this assumption correct? I think so. At worst it could trigger a build fail assuming the kernel would do some really odd struct layout reordering (which, according to the build bot, doesn't occur for any currently tested arch). Now that you highlighted this line though, I started to wonder if it would be just better to use memcpy() instead as it would avoid those casts. > > + * padding. > > + */ > > +struct kserial_rs485 { > > + __u32 flags; /* RS485 feature flags */ > > + __u32 delay_rts_before_send; /* Delay before send (milliseconds) */ > > + __u32 delay_rts_after_send; /* Delay after send (milliseconds) */ > > + struct { > > + __u8 addr_recv; > > + __u8 addr_dest; > > + }; > > Btw, can't we convert them to kernel doc? Yes, why not. -- i. --8323329-174262208-1661774957=:1928--