From owner-freebsd-hackers@freebsd.org Wed Jun 5 13:21:30 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 332E415ADBDF for ; Wed, 5 Jun 2019 13:21:30 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0F3BA82FDD; Wed, 5 Jun 2019 13:21:29 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-lf1-f68.google.com with SMTP id a9so17649616lff.7; Wed, 05 Jun 2019 06:21:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=UY1CdniDlzkNYAPJKSxbnvBh99BYNVb0WMhSovUNXsU=; b=MsTr9aMTDWAyM7i+x647sOV4Rsenvqlbev7qaVM/vnj4J/dIgufjkjuLGlCfq0ixIe kTv1cEPB1bbEajot+hQexW4YMr/868y7fkTU8913nTY5LEdpWD6rLJoUmsmxJxsrZY5l 24I0o4mZMX6I/s3Y/ueuv2L5RWVnCca0XY2gfTUzAeWc+4FiBqUH3uoIGkX9WYWj1L2e 2dZH7Auy+k0u9/FfxtXBVn+M3b9QqSujkkxJDRUF1EG33FqdRwIjys21nZQwsaQOQu1b Vc7VsG4YRrA9WCnaeBWImMYEr/qyHnO9jizPBd8N9WMsRZlYDiQOFrHxZDd6woltkV1N aYnA== X-Gm-Message-State: APjAAAWJWbx54ETDdTbaoaxPogSu4RdnLKPkuH/j+cr7gVss9jK46M2N 7I1KiZBQTKpBnF3KHdUvjqvF8QzT X-Google-Smtp-Source: APXvYqxm4S0Vv/vB9k7D9iUarbCX9T729sUw5RkNaet9aiUAWXUlI9SEPldDWo5/eLhEsMdQe/teGg== X-Received: by 2002:a19:c142:: with SMTP id r63mr21819073lff.49.1559740880906; Wed, 05 Jun 2019 06:21:20 -0700 (PDT) Received: from [192.168.0.88] (east.meadow.volia.net. [93.72.151.96]) by smtp.googlemail.com with ESMTPSA id b25sm4195323lff.42.2019.06.05.06.21.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 06:21:19 -0700 (PDT) Subject: Re: setting driver properties for a particular device To: Ian Lepore , Michael Zhilin Cc: FreeBSD Hackers References: <201905231115.x4NBFMSu037564@repo.freebsd.org> <523f92fe-c106-db6b-00d9-356913fdca5d@FreeBSD.org> <1a8fe3f8-a4d7-44f9-2b90-8b70e158f661@FreeBSD.org> From: Andriy Gapon Openpgp: preference=signencrypt Autocrypt: addr=avg@FreeBSD.org; prefer-encrypt=mutual; keydata= xsFNBFm4LIgBEADNB/3lT7f15UKeQ52xCFQx/GqHkSxEdVyLFZTmY3KyNPQGBtyvVyBfprJ7 mAeXZWfhat6cKNRAGZcL5EmewdQuUfQfBdYmKjbw3a9GFDsDNuhDA2QwFt8BmkiVMRYyvI7l N0eVzszWCUgdc3qqM6qqcgBaqsVmJluwpvwp4ZBXmch5BgDDDb1MPO8AZ2QZfIQmplkj8Y6Z AiNMknkmgaekIINSJX8IzRzKD5WwMsin70psE8dpL/iBsA2cpJGzWMObVTtCxeDKlBCNqM1i gTXta1ukdUT7JgLEFZk9ceYQQMJJtUwzWu1UHfZn0Fs29HTqawfWPSZVbulbrnu5q55R4PlQ /xURkWQUTyDpqUvb4JK371zhepXiXDwrrpnyyZABm3SFLkk2bHlheeKU6Yql4pcmSVym1AS4 dV8y0o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QFz78NbXhluwix2Tb9ETPk LIpDrtzV73CaE2aqBG/KrboXT2C67BgFtnk7T7Y7iKq4/XvEdDWscz2wws91BOXuMMd4c/c4 OmGW9m3RBLufFrOag1q5yUS9QbFfyqL6dftJP3Zq/xe+mr7sbWbhPVCQFrH3r26mpmy841ym dwQnNcsbIGiBASBSKksOvIDYKa2Wy8htPmWFTEOPRpFXdGQ27awcjjnB42nngyCK5ukZDHi6 w0qK5DNQQCkiweevCIC6wc3p67jl1EMFY5+z+zdTPb3h7LeVnGqW0qBQl99vVFgzLxchKcl0 R/paSFgwqXCZhAKMuUHncJuynDOP7z5LirUeFI8qsBAJi1rXpQoLJTVcW72swZ42IdPiboqx NbTMiNOiE36GqMcTPfKylCbF45JNX4nF9ElM0E+Y8gi4cizJYBRr2FBJgay0b9Cp Message-ID: <5ac39749-3aca-c4c9-56d2-b17d77ca318b@FreeBSD.org> Date: Wed, 5 Jun 2019 16:21:18 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 0F3BA82FDD X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of agapon@gmail.com designates 209.85.167.68 as permitted sender) smtp.mailfrom=agapon@gmail.com X-Spamd-Result: default: False [-4.07 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[FreeBSD.org]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; NEURAL_HAM_SHORT(-0.91)[-0.912,0]; RCVD_IN_DNSWL_NONE(0.00)[68.167.85.209.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; IP_SCORE(-1.15)[ipnet: 209.85.128.0/17(-3.39), asn: 15169(-2.30), country: US(-0.06)]; FORGED_SENDER(0.30)[avg@FreeBSD.org,agapon@gmail.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[68.167.85.209.rep.mailspike.net : 127.0.0.17]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[avg@FreeBSD.org,agapon@gmail.com] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2019 13:21:30 -0000 On 30/05/2019 00:40, Ian Lepore wrote: > On Wed, 2019-05-29 at 13:31 +0300, Andriy Gapon wrote: >> On 29/05/2019 13:29, Michael Zhilin wrote: >>> Hi, >>> >>> There are kenv and sysctl. Is it far from what you are looking for? >> >> No. When I said programmatically, I meant programmatically from >> within the kernel. >> > > Hmmm. Whatever you do, it's going to amount to a conspiracy of > agreement between the driver that wants to set this info and the driver > that is expected to act on it. So if you don't use the existing hints > mechanism, then you'll have to invent something new, and the gpioled > driver will have to be updated to also check that new mechanism to see > if there is any config info there that affects it. I'm not sure that's > a big win over the slight inelegance of crafting a hint string at > runtime. I think you are right. Probably, I am going to add a helper function to make that job easier. E.g., something like set_dev_hint(device_t dev, const char *name, const char *val); or perhaps set_dev_hint(device_t dev, const char *name, const char *fmt, ...); >>> On Wed, May 29, 2019 at 1:19 PM Andriy Gapon >> > wrote: >>> >>> On 23/05/2019 14:15, Andriy Gapon wrote: >>> > Author: avg >>> > Date: Thu May 23 11:15:22 2019 >>> > New Revision: 348153 >>> > URL: https://svnweb.freebsd.org/changeset/base/348153 >>> > >>> > Log: >>> > gpioled: add a new hint for initial state >>> > >>> > hint.gpioled.%d.state determines the initial state of the >>> LED when the >>> > driver takes control over it: >>> > 0 - the LED is off >>> > 1 - the LED is on >>> > -1 - the LED is kept as it was >>> >>> By the way, can anyone suggest a mechanism to set device >>> properties like this >>> one _programmatically_ ? >>> >>> I am thinking of a case where I know exactly how everything is >>> wired on a >>> platform. And there is no FDT or alike support for it. And >>> hints are not >>> possible to set up correctly (e.g., bus numbers may float). >>> So, I want to >>> create a gpioled child on a specific bus and I want to set some >>> properties for >>> the device. >>> Of course, I can probably do something like >>> kern_setenv("hints.foo.X.bar", ...) >>> using the child's name and unit number. But that feels a bit >>> cumbersome. >>> >>> And this question is not about gpioled specifically. >>> >>> IVARs is definitely not the right mechanism, because it is >>> about bus-specific >>> properties of devices on the bus. So, it is not aware of >>> properties specific to >>> a driver that attaches to a child device. -- Andriy Gapon