From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34E0DC0651F for ; Thu, 4 Jul 2019 16:43:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0116C21721 for ; Thu, 4 Jul 2019 16:43:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727101AbfGDQno (ORCPT ); Thu, 4 Jul 2019 12:43:44 -0400 Received: from ns.iliad.fr ([212.27.33.1]:40418 "EHLO ns.iliad.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbfGDQno (ORCPT ); Thu, 4 Jul 2019 12:43:44 -0400 Received: from ns.iliad.fr (localhost [127.0.0.1]) by ns.iliad.fr (Postfix) with ESMTP id 1CA612077F; Thu, 4 Jul 2019 18:43:42 +0200 (CEST) Received: from [192.168.108.49] (freebox.vlq16.iliad.fr [213.36.7.13]) by ns.iliad.fr (Postfix) with ESMTP id A205820701; Thu, 4 Jul 2019 18:43:39 +0200 (CEST) To: Wolfram Sang , Simon Horman , Peter Korsgaard Cc: I2C , linux-media , Linux ARM , Bjorn Andersson , Ard Biesheuvel , Arnd Bergmann From: Marc Gonzalez Subject: Generic get_something from an i2c_client Message-ID: <07aa1229-2b67-e191-5740-70e6ed2a8ce3@free.fr> Date: Thu, 4 Jul 2019 18:43:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP ; ns.iliad.fr ; Thu Jul 4 18:43:42 2019 +0200 (CEST) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hello, In media drivers, TS drivers typically hard-code their front-end (demod and tuner) init by loading the modules themselves. I feel this is not a good solution for SoCs, where the TS HW might be on the SoC, and the front-end be on the board. So we may have different front-ends for different boards, and the driver would have to hard-code all of them. Am I making sense? Here's an example of what I mean: https://elixir.bootlin.com/linux/latest/source/drivers/media/usb/dvb-usb-v2/dvbsky.c#L466 I've been working on defining the demod in DT, and having a phandle to the demod in the TSIF node. I've got everything working like I had hoped, but I have many ugly hacks. The TSIF driver needs to register the frontend, which is created in the demod driver. So I have: struct device_node *toto = of_parse_phandle(np, "demod", 0); if (!toto) panic("of_parse_phandle"); struct i2c_client *demod = of_find_i2c_device_by_node(toto); if (!demod) panic("of_find_i2c_device_by_node"); printk("\tdemod=%px\n", demod); struct dvb_frontend *get_fe(struct i2c_client *client); my_dvb_frontend = get_fe(demod); The problem is get_fe(). It needs to be a call-back, so that every demod can implement his own version. But only a few i2c_client's have a dvb_frontend to return. Could we have a generic void *get_something() callback in struct i2c_client? (Seems like the wrong place) How can I solve this conundrum? Maybe look above i2c, in struct device? Regards.