Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp200949rwb; Tue, 4 Oct 2022 02:48:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6AUfFAMiAeXjrIXGVNdch6zbmN+QgjXGLXyu5fMucg9w5OnCgfLlivhVgsqUH3DdZxMxrt X-Received: by 2002:a05:6402:1d55:b0:451:756e:439d with SMTP id dz21-20020a0564021d5500b00451756e439dmr22783571edb.226.1664876902871; Tue, 04 Oct 2022 02:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664876902; cv=none; d=google.com; s=arc-20160816; b=djz/ZEgsMClJXtrAf8RN/TLPbPW/yDNZ1IaJFrGyucntFz1yskzOE/wGcvbRL32WDQ b685rgXWzzaDJQzR9JAjl/lmAJc3GHmpnwJCMZR8ZNdX7eP1VJEoaJPqxVLoQ8zy/e1t 7oiUd3qh0ezkdDq8yXqBBfq44q4KdvwmAamxGt46X+sYjTOTTk+28mengVtURahCaBKq KaAgE8kdxLPZelcf/bBcQKgfdJ1ccikiycQrkBKS3Gtkf3h4Viu1h8kXsCdz1c9Vba5j bCg/1mh5BKIg6SoWFXuIbiFUOI7WVjrhrsGi6PYQ/aJ+3stfvOOLKxW52CuYN8IzlGqp FCDw== 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=uS/VMXbbSweetA/020z0Dip0Sj8VqAEsB1LoI072/ck=; b=Ca68V53ZY17NOO56NOCkPq/oeJBN4yv+zey5EAfBA3QKyD0FdgbC3ht1W67ud23pNP e+lEBNVsyJlZ4nz8gu1aI0vQjMebv7Az6A/neoPv9FuM8ftVI0VCnDt5g+LpRa3X8u5l TugFKWlFK5W6EiUqC/p54LQKIkipGB30X55lMILAk3zG6PN6mhJf4BGnj8U+IUEeYStl maCVceYp3zWa21vRS7XKg11ZA5+Pn00uxFnPAJ6fmGqbLZx3nctSfAoOE6btR0x80x9n TI4pfELoJOziuz/VvuEBNdjaOlyf1dP+q3STix8YJoat2g5UIFJMXCKXwmEUWXxv8hVi wCCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iuBI7BAK; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd22-20020a1709076e1600b0078c4a772ea7si4446253ejc.11.2022.10.04.02.47.57; Tue, 04 Oct 2022 02:48:22 -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=@linuxfoundation.org header.s=korg header.b=iuBI7BAK; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229563AbiJDIYV (ORCPT + 99 others); Tue, 4 Oct 2022 04:24:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbiJDIYS (ORCPT ); Tue, 4 Oct 2022 04:24:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C89A81C123; Tue, 4 Oct 2022 01:24:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5472D612A4; Tue, 4 Oct 2022 08:24:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BAABC433B5; Tue, 4 Oct 2022 08:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664871856; bh=L9ErYNdSZRiqO0Gq2HFs31+nFf9F85V1RMYELu0rytM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iuBI7BAK9J2P1sMpfLs4RR6S1y9bSzjaCWKtm+eMek/hfzFvNn5ECiEh8/v/soei4 RxZbawWrBRLOVUb/eSnzf1I0dv5g9K5QV7i4M4KKPp8rT/QUa1smJkENZ9fBUNj818 P0/khJwxzcaAYpWpgnks52qWw64eb64+2QY94eOw= Date: Tue, 4 Oct 2022 10:24:13 +0200 From: Greg Kroah-Hartman To: Andy Shevchenko Cc: Sakari Ailus , Heikki Krogerus , Bjorn Andersson , Prashant Malani , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Daniel Scally , "Rafael J. Wysocki" Subject: Re: [PATCH v2 1/5] device property: Keep dev_fwnode() and dev_fwnode_const() separate Message-ID: References: <20220928105746.51208-2-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Tue, Oct 04, 2022 at 11:14:14AM +0300, Andy Shevchenko wrote: > On Tue, Oct 04, 2022 at 09:55:21AM +0200, Greg Kroah-Hartman wrote: > > On Mon, Oct 03, 2022 at 08:08:58PM +0000, Sakari Ailus wrote: > > > On Mon, Oct 03, 2022 at 06:17:17PM +0200, Greg Kroah-Hartman wrote: > > ... > > > > #define kobj_to_dev(kobj) \ > > > (_Generic((kobj), \ > > > const struct kobject *: __kobj_to_dev_const, \ > > > struct kobject *: __kobj_to_dev)(kobj)) > > > > Ah, doh! I had the (kobj) part in the wrong place, thanks for that > > fix... > > > > Ok, this looks better, let me see how well the build breaks with some of > > these changes > > I believe I can rewrite my patch like this and then it will be much nicer since > we may constify all the rest without calling __dev_fwnode_const() directly. > > Are you agree? Yes, I think this is a much better option, try it and see. Below is the patch I'm running through my build systems at the moment, feel free to copy the style for your change as well. thanks, greg k-h diff --git a/include/linux/device.h b/include/linux/device.h index 424b55df0272..023ea50b1916 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -680,11 +680,27 @@ struct device_link { bool supplier_preactivated; /* Owned by consumer probe. */ }; -static inline struct device *kobj_to_dev(struct kobject *kobj) +static inline struct device *__kobj_to_dev(struct kobject *kobj) { return container_of(kobj, struct device, kobj); } +static inline const struct device *__kobj_to_dev_const(const struct kobject *kobj) +{ + return container_of(kobj, const struct device, kobj); +} + +/* + * container_of() will happily take a const * and spit back a non-const * as it + * is just doing pointer math. But we want to be a bit more careful in the + * driver code, so manually force any const * of a kobject to also be a const * + * to a device. + */ +#define kobj_to_dev(kobj) \ + _Generic((kobj), \ + const struct kobject *: __kobj_to_dev_const, \ + struct kobject *: __kobj_to_dev)(kobj) + /** * device_iommu_mapped - Returns true when the device DMA is translated * by an IOMMU