Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4445148pxb; Tue, 10 Nov 2020 17:11:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrioDX7gtxbvph8w9tEIKP3jguH4ep/4dgMrUtY83PjYB2AvLcjaeYqpAD8yTeXg36/oqC X-Received: by 2002:a17:906:17d6:: with SMTP id u22mr10144523eje.399.1605057078520; Tue, 10 Nov 2020 17:11:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605057078; cv=none; d=google.com; s=arc-20160816; b=eKmWeK4F6SAR3S0zAB/WfsVF5jIA6EUimO0jdXrnMjRtOqFwSnu6vBLtWy8NQWhf3b 7nOB80ihyblwlVK1iJR51O5PcxcM0uJThJxj9qBfQN0B7hf/IKQ5lqCz4zpyuk3FhuAp HbT/O7JN4XSlI3rYSeMgrrqV4J9Jo7XeFpFoUJPC5XpI/XS3AJkZTqrhlfyLsAQV2tQy bn9ev/6155mxmA3Vc35PQOMBBSRE4tkOuivnDLz4jZXlcR7r2lv2NV+81wXAv3NnaUiw RezlpYt4WA89lAD2cNPCXXxzhGoK3ogNwZfJYuVtGivigfFgTKBGu177RDHz9FX0FHG/ 2e9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zQ2YZ7wvYdXCryYm5A3rqiOGevl/hLPKyvgu8SbKo14=; b=u/Tw0OkPuJCgkluxNFwi6PqZ0T4i6ygVig/jI98l0PIW4Im9oNPBHdTiLas3lBRbtV crp6XiHXfnrZ+lmpNaP/XqN/usuODqZt88Ep2ymi3mmvOCogHDZ6AFSyM1ZnAhWjPC5X WPcPFar5GQWBu6MUjztYo7gvApEIsVcz/21hs2H59LwMBquMOB2VNLog0hK9a4Gpxpv9 j/zJRUhdxrDiBtkMSORmJlSd1eGf0yAVceZUwJXEQBmb9B385i9FnPpAwGBj28A7VkE3 A3wGwvyG259UIG/sI9ALHClgnkwPRS/wyGaxTp00kpNLPjH4Gs3nCIahMLqNsTMZ4zDe lEdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OIAHF4sU; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si309765eds.580.2020.11.10.17.10.51; Tue, 10 Nov 2020 17:11:18 -0800 (PST) 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=@linaro.org header.s=google header.b=OIAHF4sU; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731984AbgKKBFm (ORCPT + 99 others); Tue, 10 Nov 2020 20:05:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727275AbgKKBFl (ORCPT ); Tue, 10 Nov 2020 20:05:41 -0500 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D19F0C0613D1 for ; Tue, 10 Nov 2020 17:05:37 -0800 (PST) Received: by mail-lf1-x141.google.com with SMTP id f11so886908lfs.3 for ; Tue, 10 Nov 2020 17:05:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zQ2YZ7wvYdXCryYm5A3rqiOGevl/hLPKyvgu8SbKo14=; b=OIAHF4sUEZIlYdTykmcU7LXhEJz+9V6MsuW9lWVY8EIBo6fIuf+nzL9mybVcKjYtg9 BxcKPbSxQn4CuFNnIpVqe/OFYrEjmBKLT5W1DAQQc2krQau/NxBr8UxJd9YEzNcf2M14 i0/OQdBnyys2Pv84Lo87gx2wBgYyQjyeWW3yteKgseOyEjGhfN28F7HMfKLkxlUUs8Ui wrlpd8B6dO5UnYqXDksXG4naiVmVM+Nz2cDmCFZgF7fPoW2bhFTzWzMiEW0VRgbuHaJ1 yPY1uoSYtiRuTOnjHY62FOz3ld69uI7KvWaP4rZqBz8exBloe1k74C2urxnvA+DksIBU Qg+A== 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=zQ2YZ7wvYdXCryYm5A3rqiOGevl/hLPKyvgu8SbKo14=; b=BL9cxtPsKHS8VLMxyEfXJwZdPH0Bs+1J2dr7ND4ZpwM3roxlUUzBWBqRyKV/xrUgUB LETlCXa4lUuRWeueDHeOSZw2JeD8xh+EFjzODRBFPOjnn+9644hMrXzuU5DyE69cb3N6 fu/KRgwbUMn6/QYxd3lL0aSR5Zmbh/4StFllrJ/In9uBf8060Gj7LB4SsIo0M/dGy5da 5nrfYNpxh9Ey47RedukEwP6MovMY2CITDjqbQREhz9Ws8tVP1saHrmtwgAkCesYxWX/N 3tjSHkktr+cQZ/do4bB4sEauh3uUeN5jvnl1qSxK5Ts3M3FNMz2uAXRJEE0R7ehhFx4z AqLQ== X-Gm-Message-State: AOAM533aADuKches1JFx204LMVRRliy4uJ9iBce3DMbs33vEfkBPg2/J P/S1pL5myMoLL1K/3dRgikPpZPL0x3FrWghhI0WDKQ== X-Received: by 2002:a05:6512:3225:: with SMTP id f5mr8058036lfe.441.1605056730290; Tue, 10 Nov 2020 17:05:30 -0800 (PST) MIME-Version: 1.0 References: <20201106150706.29089-1-TheSven73@gmail.com> In-Reply-To: From: Linus Walleij Date: Wed, 11 Nov 2020 02:05:19 +0100 Message-ID: Subject: Re: [PATCH v1] spi: fix client driver breakages when using GPIO descriptors To: Sven Van Asbroeck Cc: Andy Shevchenko , Mark Brown , Jonathan Cameron , Simon Han , Lukas Wunner , linux-spi , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 9, 2020 at 3:41 PM Sven Van Asbroeck wrote: > On Mon, Nov 9, 2020 at 9:24 AM Andy Shevchenko > wrote: > > > > Sounds like "many SPI drivers have to be fixed". > > I don't disagree. Fact is that after the imx cspi bus driver was converted > to gpio descriptors, most spi client drivers broke. It would be great if this > could be fixed. Any method that the community can find a consensus on, > would be great :) I think your patch is the quick fix. I would say that anything that has: spi->mode = ... is essentially broken. The core sets up vital things in .mode from e.g. device tree in of_spi_parse_dt(): /* Mode (clock phase/polarity/etc.) */ if (of_property_read_bool(nc, "spi-cpha")) spi->mode |= SPI_CPHA; if (of_property_read_bool(nc, "spi-cpol")) spi->mode |= SPI_CPOL; if (of_property_read_bool(nc, "spi-3wire")) spi->mode |= SPI_3WIRE; if (of_property_read_bool(nc, "spi-lsb-first")) spi->mode |= SPI_LSB_FIRST; if (of_property_read_bool(nc, "spi-cs-high")) spi->mode |= SPI_CS_HIGH; All this gets overwritten and ignored when a client just assigns mode like that. Not just SPI_CS_HIGH. I doubt things are different with ACPI. > One the one hand: the fact that many spi client drivers just overwrite > flags and values in their parent bus structure, doesn't sound idiomatic. > I guess those spi->... values should really be opaque, and we should > be using accessor functions, eg.: > > static int acme_probe(struct spi_device *spi) > { > ... > // won't touch SPI_CS_HIGH flag > spi_set_mode_clock(spi, SPI_MODE_0); > ... > } I would just make sure to affect the flags that matters to my driver, it's just bits. spi->mode &= ~FOO; spi->mode |= BAR; > On the other hand, it sounds very confusing to set SPI_CS_HIGH on > all spi buses that use gpio descriptors: especially because gpiolib > already handles absolutely everything related to polarity. As long as gpiolib gets a 1 for asserted and a 0 for deasserted it will be happy. I'm not against your patch, it makes the codepath cleaner so in a way it is good. Yours, Linus Walleij