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=-5.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham 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 2F76BC282C3 for ; Thu, 24 Jan 2019 11:06:41 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CCA67218A2 for ; Thu, 24 Jan 2019 11:06:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aqpv3Yju" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCA67218A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1gmcq2-00017s-PW; Thu, 24 Jan 2019 06:06:26 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1gmcq1-00017l-TY for kernelnewbies@kernelnewbies.org; Thu, 24 Jan 2019 06:06:25 -0500 Received: by mail-pf1-x430.google.com with SMTP id y126so2812858pfb.4 for ; Thu, 24 Jan 2019 03:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6MYxXHYEdltmvJG+e5jxvanHR7sIOsG/IVXso1mMg6Y=; b=aqpv3Yjuh0iF6gZNBZKkhsID3twXATNePI23Fwvei2k8HDXKDNhWoDu07KnUw4blLr bPt6xNjUWa79I0dkroIm05/f28AJC7qGulLarKh4XIYhd6fkoRFKAhKgqxKM2SRm6Dua H85mfBzZ7a4QDF8CdoSS8G95ZpISnDm8QeahWRVtf/lK9YdxRCU38p8l0m66ZaSWbF8Y RKwxIYnPfZo7jOjQk62ZPDbQzeA+rrZ4tlvnDdmyhepCkDFkpiJnZfeeuFe8o47sLhPU XnIJ3H+OrQL2GVeCJK3FHBzvaF9vcvIXr3iQNGiKZULoiL7OTcW+BNh/sHliumeJeny4 3xIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6MYxXHYEdltmvJG+e5jxvanHR7sIOsG/IVXso1mMg6Y=; b=RLLGVUpcj21MKdWYVTknsGw2ehLM2k/6MPz/5pk0hiE7CNzR3sh0ggxmsF5eX7z0p7 fYUzcAznNoq0QESQnW/7w/fbguw0U6TqWUckFiH2KmIr91m5QMaTyJsDLTdYgMlEA+YG 6EP+I6kM9QdHKk1TgWcGvr2PHxME2qdGdsEeZlWpw7qjrgrkxlfbi2A+BAsdYiLuDAHi xXRFbpGfCFKiwoYAVNOzf/yXVIwHFwpoLLFfjMelv4SI1raSCNaRkiVg0P2KogsfztgR +cBoF66LLSFK6Dh2nJ9PWA0hRogkrF8P4BDqUXZTwP97hdRjIESNhjbLLGg+/goyAdSf s1hQ== X-Gm-Message-State: AJcUukfsfTkA9UsmcnQZb+vn1Z/JJ0jCx8pHtU5MLYBv4KhhJZozA9fh IOqDQFLjbcEaM97awCge+tMK0XOc X-Google-Smtp-Source: ALg8bN542gwdUSWBHvA0V8v9TIgbYnnmphiqW+qQzFaa6KbHjKgQDjZVTd/dO5YtF5HyZ9r264kEFw== X-Received: by 2002:a63:5f89:: with SMTP id t131mr5618522pgb.26.1548327923147; Thu, 24 Jan 2019 03:05:23 -0800 (PST) Received: from himanshu-Vostro-3559 ([103.233.116.134]) by smtp.gmail.com with ESMTPSA id l11sm28424125pff.65.2019.01.24.03.05.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Jan 2019 03:05:22 -0800 (PST) Date: Thu, 24 Jan 2019 16:35:16 +0530 From: Himanshu Jha To: Bharath Vedartham Subject: Re: drivers: iio: dummy: Unable to add channels to simple_dummy_channel Message-ID: <20190124110516.GB13680@himanshu-Vostro-3559> References: <20190123175556.GA1039@bhar.linux> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190123175556.GA1039@bhar.linux> User-Agent: Mutt/1.9.4 (2018-02-28) Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Wed, Jan 23, 2019 at 11:25:59PM +0530, Bharath Vedartham wrote: > I am trying to add the 3-axis compass data channels to the > simple_dummy_channel. I have mounted configfs and am able to load the > modules correctly. Is this the right approach? printk is not printing > anything to syslogs. > > This is part of the iio_tasks in (I have finished the first 2 tasks): > > https://kernelnewbies.org/IIO_tasks > > output of lsmod | grep dummy: > > iio_dummy 20480 2 > iio_dummy_evgen 16384 1 iio_dummy > > output of ls /sys/bus/iio/devices/iio:device0/: > > buffer in_sampling_frequency > in_voltage-voltage_scale > current_timestamp_clock in_steps_calibheight name > dev in_steps_en out_voltage0_raw > events in_steps_input power > in_accel_x_calibbias in_voltage0_offset scan_elements > in_accel_x_calibscale in_voltage0_raw subsystem > in_accel_x_raw in_voltage0_scale trigger > in_activity_running_input in_voltage1-voltage2_raw uevent > in_activity_walking_input in_voltage3-voltage4_raw > > I have also put the diff.Added channel to iio_dummy_channels and added > element to enum simple_dummy_scan_elements. > > Thank you, > Bharath > > --- > drivers/iio/dummy/iio_simple_dummy.c | 43 ++++++++++++++++++++++++++++++++++++ > drivers/iio/dummy/iio_simple_dummy.h | 3 +++ > 2 files changed, 46 insertions(+) > > diff --git a/drivers/iio/dummy/iio_simple_dummy.c b/drivers/iio/dummy/iio_simple_dummy.c > index 6205247..306e0cd 100644 > --- a/drivers/iio/dummy/iio_simple_dummy.c > +++ b/drivers/iio/dummy/iio_simple_dummy.c > @@ -268,6 +268,48 @@ static const struct iio_chan_spec iio_dummy_channels[] = { > .num_event_specs = 1, > #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ > }, > + { > + .type = IIO_MAGN, > + .modified = 1, > + .channel2 = IIO_MOD_X, > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), > + .scan_index = DUMMY_INDEX_MAGNX, > + .scan_type = { > + .sign = 'u', > + .realbits = 16, > + .storagebits = 16, > + .shift = 0, > + }, > + }, > + { > + .type = IIO_MAGN, > + .modified = 1, > + .channel2 = IIO_MOD_Y, > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), > + .scan_index = DUMMY_INDEX_MAGNY, > + .scan_type = { > + .sign = 'u', > + .realbits= 16, > + .storagebits = 16, > + .shift = 0, > + }, > + }, > + { > + .type = IIO_MAGN, > + .modified = 1, > + .channel2 = IIO_MOD_Z, > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), > + .scan_index = DUMMY_INDEX_MAGNZ, > + .scan_type = { > + .sign = 'u', > + .realbits = 16, > + .storagebits = 16, > + .shift = 0, > + }, > + }, > }; > > /** > @@ -621,6 +663,7 @@ static struct iio_sw_device *iio_dummy_probe(const char *name) > /* Provide description of available channels */ > indio_dev->channels = iio_dummy_channels; > indio_dev->num_channels = ARRAY_SIZE(iio_dummy_channels); > + printk(KERN_DEBUG "No of channels are %d\n",indio_dev -> num_channels); > > /* > * Provide device type specific interface functions and > diff --git a/drivers/iio/dummy/iio_simple_dummy.h b/drivers/iio/dummy/iio_simple_dummy.h > index f7005c3..be6eff0 100644 > --- a/drivers/iio/dummy/iio_simple_dummy.h > +++ b/drivers/iio/dummy/iio_simple_dummy.h > @@ -110,6 +110,9 @@ enum iio_simple_dummy_scan_elements { > DUMMY_INDEX_DIFFVOLTAGE_1M2, > DUMMY_INDEX_DIFFVOLTAGE_3M4, > DUMMY_INDEX_ACCELX, > + DUMMY_INDEX_MAGNX, > + DUMMY_INDEX_MAGNY, > + DUMMY_INDEX_MAGNZ, > }; This looks good. But think about what would happen if you read one of those attributes ? Like if you do: # cat in_accel_x_raw 34 (Looking at hardcoded value in the dummy source) st->accel_val = 34; -- Himanshu Jha Undergraduate Student Department of Electronics & Communication Guru Tegh Bahadur Institute of Technology _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies