Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5190202imd; Tue, 30 Oct 2018 13:25:37 -0700 (PDT) X-Google-Smtp-Source: AJdET5c/KTxJZTfHxz1iHHJnaIVQ6JVHjJIqwI0TJi7K1VsralirNTbxEpd6kiTJyS2umT867LGZ X-Received: by 2002:a63:2f07:: with SMTP id v7mr187911pgv.368.1540931137343; Tue, 30 Oct 2018 13:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540931137; cv=none; d=google.com; s=arc-20160816; b=IR841HHxHzGS9KfnHGO3y3Zz26IEeijIqBJChzdkYP/a9KpJdneOEMgvGSavDBM3S7 bgSxfv1PyIFzJSELxXiDE+vNUZ7zqTLeDdvUUKfAXdStiaWA0asINtKikz3cS3t3avmQ N+6uPKJ5M6Xe+J0iXUPjA9/shpg59Ci6FafRjVy4rY9Q9A9VAE1sQ5Y7EDkxrPkcf9IC K/URQ3yaQjWM0uPLe5HR8vrXLPTcwhGqTKRvWygAM6pGpFJmsURwgNHGbTWtkMXtQxyD hqZSyKbjGOMy+IE/DQoBYJOntMm24mNNgK4Vby7fhO4W1HxquJt1vATqItPExnWjyZbF j2qg== 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 :references:in-reply-to:mime-version:dkim-signature; bh=RpTo1KM0PRBTIdeibAxOamsQPtaTgRc/rVpIA1Y7jxI=; b=ntED5atZ9bYHXFvMh9Ayu+bTmbGjYdnnrRBEKeXSujm2PPz3vlkAI/zL6gvhucvS9v jMfZcA0CyECt6DhKYkbRF83QULqg0TZSBdnWBMJ5drPawroZ2mOqEfyP8mdvr4JWILcv YrFTkJdsi7e77lS3EGQxfRid//i7ATu+JikyNOFHOAqcIyKoSFkNJILsR4eMJA5dKLLa DO8BLdOPlAPSCbyhEqbhdGFWATqk9MkYEwFJnbjn0eWxuwFXTte56uvgX1GTcGloBD2Y QJsZzZ6VxvLqqe69pxC10a4+UpVFwCR+XHpWBQQFfqUxhK/ihfQ0cSZIsKzC8hT623Tw qduA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mLxXlZ9F; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5-v6si24799829pgg.559.2018.10.30.13.25.21; Tue, 30 Oct 2018 13:25:37 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mLxXlZ9F; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727869AbeJaFDv (ORCPT + 99 others); Wed, 31 Oct 2018 01:03:51 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:43106 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbeJaFDv (ORCPT ); Wed, 31 Oct 2018 01:03:51 -0400 Received: by mail-qk1-f195.google.com with SMTP id r71so8110326qkr.10; Tue, 30 Oct 2018 13:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=RpTo1KM0PRBTIdeibAxOamsQPtaTgRc/rVpIA1Y7jxI=; b=mLxXlZ9FdIyl49+VmVfhD8nx3bpU/aBaM3XgI6kO+rQfhK5cYX/Fo5ITW04Akdum16 O3jGu4gdMuaakN6VqHiGQgGzFAkiOTAsoNAbZwa73SvZ1wH/RGjQkr8847MEn4atSe6k /k9cyI1vS6HTCt4lsgKUKvr/nRS/EXt6ghEusgYqYMZPHUmZnphRew1JS44cmlcHAxaj uqiWpb1vIlSVtBGhZ7Nt4SilbHL2dHgcb1Axs/02IKdGGXbl4ZaLWsu77ogIa0sjXOCK DW+v1MNWOOub51DgC5ScygStbA8DThdsBDb7xZixEgaQ2N9p4itErswFAp9JFjAVqhqc qXFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=RpTo1KM0PRBTIdeibAxOamsQPtaTgRc/rVpIA1Y7jxI=; b=JgAJPa5sjYqjv2+A2yAZNLNNc5bQwQQqWpnaBTt4hI0nrAVTqWxPJxHb9/xzxnVLSk EkB6B7oUyMdmYffa69xqHKAybBKuqV6ZblXdnVNPA88CnvjQdKqWm995dJGePuXWZbIU DXRolg3TyU4PK8J/bNrvzOmpBP5x6tmvgicRNOm4yTSTXtyXAnjv/xTL5/YmSzREfSqZ i7pUGPZlyftF5Ec9AKYpBVXWj4G83/3H8R0eIGD3sgyAMiTg1V0+thpRDDJ6rwP9gq72 LEYHkeouWz6aqxDuWOenOzOeCLlkOXxfBUswpaPC2gT+l7H9jR6DWbflecFWP5RAj0oA LkPg== X-Gm-Message-State: AGRZ1gKSAYQjktEnLhfqgKeH6Jli3Kd9YpiRuv5scb6ZlY2hTeyiaS9o AxgBq18NGzayvmcj/B0D1J9+FvVd9ps7rSfOFPo= X-Received: by 2002:a37:4116:: with SMTP id o22-v6mr123885qka.107.1540930135735; Tue, 30 Oct 2018 13:08:55 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:988d:0:0:0:0:0 with HTTP; Tue, 30 Oct 2018 13:08:54 -0700 (PDT) In-Reply-To: References: From: Arnd Bergmann Date: Tue, 30 Oct 2018 21:08:54 +0100 X-Google-Sender-Auth: pv2tco8mjbSvl20gHyF3lxxk040 Message-ID: Subject: Re: [PATCH V2 4/6] usb: ohci-platform: Add support for Broadcom STB SoC's To: Alan Cooper Cc: ": Linux Kernel Mailing List" , Alan Stern , Alban Bedel , Alex Elder , Andrew Morton , Avi Fishman , bcm-kernel-feedback-list@broadcom.com, Bjorn Andersson , Chunfeng Yun , David Miller , DTML , Dmitry Osipenko , gregkh , "Gustavo A. R. Silva" , Hans de Goede , James Hogan , Jianguo Sun , Johan Hovold , Kees Cook , USB list , Lu Baolu , Mark Rutland , Martin Blumenstingl , Mathias Nyman , Mathias Nyman , Mauro Carvalho Chehab , Rishabh Bhatnagar , Rob Herring , Roger Quadros 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 10/30/18, Alan Cooper wrote: >> On 10/24/18 3:11 AM, Arnd Bergmann wrote: >> >> On Wed, Oct 17, 2018 at 11:30 PM Al Cooper wrote: >> >> Add support for Broadcom STB SoC's to the ohci platform driver. >> >> Signed-off-by: Al Cooper >> --- >> drivers/usb/host/ohci-platform.c | 35 >> +++++++++++++++++++++++++++++------ >> include/linux/usb/ohci_pdriver.h | 1 + >> 2 files changed, 30 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/usb/host/ohci-platform.c > b/drivers/usb/host/ohci-platform.c >> index 65a1c3fdc88c..363d6fa676a5 100644 >> --- a/drivers/usb/host/ohci-platform.c >> +++ b/drivers/usb/host/ohci-platform.c >> @@ -22,6 +22,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -99,12 +100,24 @@ static int ohci_platform_probe(struct > platform_device *dev) >> if (usb_disabled()) >> return -ENODEV; >> >> - /* >> - * Use reasonable defaults so platforms don't have to provide > these >> - * with DT probing on ARM. >> - */ >> - if (!pdata) >> - pdata = &ohci_platform_defaults; >> + if (!pdata) { >> + const struct usb_ohci_pdata *match_pdata; >> + >> + match_pdata = of_device_get_match_data(&dev->dev); >> + if (match_pdata) { >> + pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), >> + GFP_KERNEL); >> + if (!pdata) >> + return -ENOMEM; >> + *pdata = *match_pdata; >> >> It looks like you copy the const pdata to get a non-const version. >> Have you tried >> propagating the 'const' modifier so that users can rely on that here? > > The problem is that the const pdata from of_device_get_match() needs to be > saved in device->platform_data which is not a const pointer (and can't be > changed). How can I propagate the "const" to solve the problem? Ah, I see your problem, and unfortunately don't have an easy answer. You could split up the structure between a constant part and a non-constant part, and have the latter be what gets put into the platform_data, but that wouldn't really be much nicer than what you have here. You could use devm_kmemdup() to save a few lines to simplify your code without any other changes maybe, but it doesn't solve the fact that the mismatch between platform_data being non-const and of_match_data being const is a bit ugly. Arnd