Re: [PATCH 2/2] media: dvb: represent min/max/step/tolerance freqs in Hz

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Mauro,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.18-rc3 next-20180704]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Mauro-Carvalho-Chehab/DVB-represent-frequencies-at-tuner-frontend-info-in-Hz/20180705-105703
base:   git://linuxtv.org/media_tree.git master
config: x86_64-randconfig-x004-201826 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/media/dvb-core/dvb_frontend.c: In function 'dvb_frontend_handle_ioctl':
>> drivers/media/dvb-core/dvb_frontend.c:2396:25: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess]
      memset(info, 0, sizeof(info));
                            ^

vim +2396 drivers/media/dvb-core/dvb_frontend.c

  2295	
  2296	static int dvb_frontend_handle_ioctl(struct file *file,
  2297					     unsigned int cmd, void *parg)
  2298	{
  2299		struct dvb_device *dvbdev = file->private_data;
  2300		struct dvb_frontend *fe = dvbdev->priv;
  2301		struct dvb_frontend_private *fepriv = fe->frontend_priv;
  2302		struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  2303		int i, err = -ENOTSUPP;
  2304	
  2305		dev_dbg(fe->dvb->device, "%s:\n", __func__);
  2306	
  2307		switch (cmd) {
  2308		case FE_SET_PROPERTY: {
  2309			struct dtv_properties *tvps = parg;
  2310			struct dtv_property *tvp = NULL;
  2311	
  2312			dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
  2313				__func__, tvps->num);
  2314			dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
  2315				__func__, tvps->props);
  2316	
  2317			/*
  2318			 * Put an arbitrary limit on the number of messages that can
  2319			 * be sent at once
  2320			 */
  2321			if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
  2322				return -EINVAL;
  2323	
  2324			tvp = memdup_user((void __user *)tvps->props, tvps->num * sizeof(*tvp));
  2325			if (IS_ERR(tvp))
  2326				return PTR_ERR(tvp);
  2327	
  2328			for (i = 0; i < tvps->num; i++) {
  2329				err = dtv_property_process_set(fe, file,
  2330							       (tvp + i)->cmd,
  2331							       (tvp + i)->u.data);
  2332				if (err < 0) {
  2333					kfree(tvp);
  2334					return err;
  2335				}
  2336			}
  2337			kfree(tvp);
  2338			err = 0;
  2339			break;
  2340		}
  2341		case FE_GET_PROPERTY: {
  2342			struct dtv_properties *tvps = parg;
  2343			struct dtv_property *tvp = NULL;
  2344			struct dtv_frontend_properties getp = fe->dtv_property_cache;
  2345	
  2346			dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
  2347				__func__, tvps->num);
  2348			dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
  2349				__func__, tvps->props);
  2350	
  2351			/*
  2352			 * Put an arbitrary limit on the number of messages that can
  2353			 * be sent at once
  2354			 */
  2355			if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
  2356				return -EINVAL;
  2357	
  2358			tvp = memdup_user((void __user *)tvps->props, tvps->num * sizeof(*tvp));
  2359			if (IS_ERR(tvp))
  2360				return PTR_ERR(tvp);
  2361	
  2362			/*
  2363			 * Let's use our own copy of property cache, in order to
  2364			 * avoid mangling with DTV zigzag logic, as drivers might
  2365			 * return crap, if they don't check if the data is available
  2366			 * before updating the properties cache.
  2367			 */
  2368			if (fepriv->state != FESTATE_IDLE) {
  2369				err = dtv_get_frontend(fe, &getp, NULL);
  2370				if (err < 0) {
  2371					kfree(tvp);
  2372					return err;
  2373				}
  2374			}
  2375			for (i = 0; i < tvps->num; i++) {
  2376				err = dtv_property_process_get(fe, &getp,
  2377							       tvp + i, file);
  2378				if (err < 0) {
  2379					kfree(tvp);
  2380					return err;
  2381				}
  2382			}
  2383	
  2384			if (copy_to_user((void __user *)tvps->props, tvp,
  2385					 tvps->num * sizeof(struct dtv_property))) {
  2386				kfree(tvp);
  2387				return -EFAULT;
  2388			}
  2389			kfree(tvp);
  2390			err = 0;
  2391			break;
  2392		}
  2393	
  2394		case FE_GET_INFO: {
  2395			struct dvb_frontend_info *info = parg;
> 2396			memset(info, 0, sizeof(info));
  2397	
  2398			dvb_frontend_get_frequency_limits(fe, &info->frequency_min, &info->frequency_max);
  2399			strcpy(info->name, fe->ops.info.name);
  2400			info->frequency_stepsize = fe->ops.info.frequency_stepsize_hz;
  2401			info->frequency_tolerance = fe->ops.info.frequency_tolerance_hz;
  2402			info->symbol_rate_min = fe->ops.info.symbol_rate_min;
  2403			info->symbol_rate_max = fe->ops.info.symbol_rate_max;
  2404			info->symbol_rate_tolerance = fe->ops.info.symbol_rate_tolerance;
  2405			info->caps = fe->ops.info.caps;
  2406	
  2407			/* If the standard is for satellite, convert frequencies to kHz */
  2408			switch (c->delivery_system) {
  2409			case SYS_DVBS:
  2410			case SYS_DVBS2:
  2411			case SYS_TURBO:
  2412			case SYS_ISDBS:
  2413				info->frequency_stepsize = fe->ops.info.frequency_stepsize_hz / kHz;
  2414				info->frequency_tolerance = fe->ops.info.frequency_tolerance_hz / kHz;
  2415				break;
  2416			default:
  2417				info->frequency_stepsize = fe->ops.info.frequency_stepsize_hz;
  2418				info->frequency_tolerance = fe->ops.info.frequency_tolerance_hz;
  2419				break;
  2420			}
  2421	
  2422			/*
  2423			 * Associate the 4 delivery systems supported by DVBv3
  2424			 * API with their DVBv5 counterpart. For the other standards,
  2425			 * use the closest type, assuming that it would hopefully
  2426			 * work with a DVBv3 application.
  2427			 * It should be noticed that, on multi-frontend devices with
  2428			 * different types (terrestrial and cable, for example),
  2429			 * a pure DVBv3 application won't be able to use all delivery
  2430			 * systems. Yet, changing the DVBv5 cache to the other delivery
  2431			 * system should be enough for making it work.
  2432			 */
  2433			switch (dvbv3_type(c->delivery_system)) {
  2434			case DVBV3_QPSK:
  2435				info->type = FE_QPSK;
  2436				break;
  2437			case DVBV3_ATSC:
  2438				info->type = FE_ATSC;
  2439				break;
  2440			case DVBV3_QAM:
  2441				info->type = FE_QAM;
  2442				break;
  2443			case DVBV3_OFDM:
  2444				info->type = FE_OFDM;
  2445				break;
  2446			default:
  2447				dev_err(fe->dvb->device,
  2448					"%s: doesn't know how to handle a DVBv3 call to delivery system %i\n",
  2449					__func__, c->delivery_system);
  2450				info->type = FE_OFDM;
  2451			}
  2452			dev_dbg(fe->dvb->device, "%s: current delivery system on cache: %d, V3 type: %d\n",
  2453				__func__, c->delivery_system, info->type);
  2454	
  2455			/* Set CAN_INVERSION_AUTO bit on in other than oneshot mode */
  2456			if (!(fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT))
  2457				info->caps |= FE_CAN_INVERSION_AUTO;
  2458			err = 0;
  2459			break;
  2460		}
  2461	
  2462		case FE_READ_STATUS: {
  2463			enum fe_status *status = parg;
  2464	
  2465			/* if retune was requested but hasn't occurred yet, prevent
  2466			 * that user get signal state from previous tuning */
  2467			if (fepriv->state == FESTATE_RETUNE ||
  2468			    fepriv->state == FESTATE_ERROR) {
  2469				err = 0;
  2470				*status = 0;
  2471				break;
  2472			}
  2473	
  2474			if (fe->ops.read_status)
  2475				err = fe->ops.read_status(fe, status);
  2476			break;
  2477		}
  2478	
  2479		case FE_DISEQC_RESET_OVERLOAD:
  2480			if (fe->ops.diseqc_reset_overload) {
  2481				err = fe->ops.diseqc_reset_overload(fe);
  2482				fepriv->state = FESTATE_DISEQC;
  2483				fepriv->status = 0;
  2484			}
  2485			break;
  2486	
  2487		case FE_DISEQC_SEND_MASTER_CMD:
  2488			if (fe->ops.diseqc_send_master_cmd) {
  2489				struct dvb_diseqc_master_cmd *cmd = parg;
  2490	
  2491				if (cmd->msg_len > sizeof(cmd->msg)) {
  2492					err = -EINVAL;
  2493					break;
  2494				}
  2495				err = fe->ops.diseqc_send_master_cmd(fe, cmd);
  2496				fepriv->state = FESTATE_DISEQC;
  2497				fepriv->status = 0;
  2498			}
  2499			break;
  2500	
  2501		case FE_DISEQC_SEND_BURST:
  2502			if (fe->ops.diseqc_send_burst) {
  2503				err = fe->ops.diseqc_send_burst(fe,
  2504							(enum fe_sec_mini_cmd)parg);
  2505				fepriv->state = FESTATE_DISEQC;
  2506				fepriv->status = 0;
  2507			}
  2508			break;
  2509	
  2510		case FE_SET_TONE:
  2511			if (fe->ops.set_tone) {
  2512				err = fe->ops.set_tone(fe,
  2513						       (enum fe_sec_tone_mode)parg);
  2514				fepriv->tone = (enum fe_sec_tone_mode)parg;
  2515				fepriv->state = FESTATE_DISEQC;
  2516				fepriv->status = 0;
  2517			}
  2518			break;
  2519	
  2520		case FE_SET_VOLTAGE:
  2521			if (fe->ops.set_voltage) {
  2522				err = fe->ops.set_voltage(fe,
  2523							  (enum fe_sec_voltage)parg);
  2524				fepriv->voltage = (enum fe_sec_voltage)parg;
  2525				fepriv->state = FESTATE_DISEQC;
  2526				fepriv->status = 0;
  2527			}
  2528			break;
  2529	
  2530		case FE_DISEQC_RECV_SLAVE_REPLY:
  2531			if (fe->ops.diseqc_recv_slave_reply)
  2532				err = fe->ops.diseqc_recv_slave_reply(fe, parg);
  2533			break;
  2534	
  2535		case FE_ENABLE_HIGH_LNB_VOLTAGE:
  2536			if (fe->ops.enable_high_lnb_voltage)
  2537				err = fe->ops.enable_high_lnb_voltage(fe, (long)parg);
  2538			break;
  2539	
  2540		case FE_SET_FRONTEND_TUNE_MODE:
  2541			fepriv->tune_mode_flags = (unsigned long)parg;
  2542			err = 0;
  2543			break;
  2544	
  2545		/* DEPRECATED dish control ioctls */
  2546	
  2547		case FE_DISHNETWORK_SEND_LEGACY_CMD:
  2548			if (fe->ops.dishnetwork_send_legacy_command) {
  2549				err = fe->ops.dishnetwork_send_legacy_command(fe,
  2550								 (unsigned long)parg);
  2551				fepriv->state = FESTATE_DISEQC;
  2552				fepriv->status = 0;
  2553			} else if (fe->ops.set_voltage) {
  2554				/*
  2555				 * NOTE: This is a fallback condition.  Some frontends
  2556				 * (stv0299 for instance) take longer than 8msec to
  2557				 * respond to a set_voltage command.  Those switches
  2558				 * need custom routines to switch properly.  For all
  2559				 * other frontends, the following should work ok.
  2560				 * Dish network legacy switches (as used by Dish500)
  2561				 * are controlled by sending 9-bit command words
  2562				 * spaced 8msec apart.
  2563				 * the actual command word is switch/port dependent
  2564				 * so it is up to the userspace application to send
  2565				 * the right command.
  2566				 * The command must always start with a '0' after
  2567				 * initialization, so parg is 8 bits and does not
  2568				 * include the initialization or start bit
  2569				 */
  2570				unsigned long swcmd = ((unsigned long)parg) << 1;
  2571				ktime_t nexttime;
  2572				ktime_t tv[10];
  2573				int i;
  2574				u8 last = 1;
  2575	
  2576				if (dvb_frontend_debug)
  2577					dprintk("%s switch command: 0x%04lx\n",
  2578						__func__, swcmd);
  2579				nexttime = ktime_get_boottime();
  2580				if (dvb_frontend_debug)
  2581					tv[0] = nexttime;
  2582				/* before sending a command, initialize by sending
  2583				 * a 32ms 18V to the switch
  2584				 */
  2585				fe->ops.set_voltage(fe, SEC_VOLTAGE_18);
  2586				dvb_frontend_sleep_until(&nexttime, 32000);
  2587	
  2588				for (i = 0; i < 9; i++) {
  2589					if (dvb_frontend_debug)
  2590						tv[i + 1] = ktime_get_boottime();
  2591					if ((swcmd & 0x01) != last) {
  2592						/* set voltage to (last ? 13V : 18V) */
  2593						fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18);
  2594						last = (last) ? 0 : 1;
  2595					}
  2596					swcmd = swcmd >> 1;
  2597					if (i != 8)
  2598						dvb_frontend_sleep_until(&nexttime, 8000);
  2599				}
  2600				if (dvb_frontend_debug) {
  2601					dprintk("%s(%d): switch delay (should be 32k followed by all 8k)\n",
  2602						__func__, fe->dvb->num);
  2603					for (i = 1; i < 10; i++)
  2604						pr_info("%d: %d\n", i,
  2605							(int)ktime_us_delta(tv[i], tv[i - 1]));
  2606				}
  2607				err = 0;
  2608				fepriv->state = FESTATE_DISEQC;
  2609				fepriv->status = 0;
  2610			}
  2611			break;
  2612	
  2613		/* DEPRECATED statistics ioctls */
  2614	
  2615		case FE_READ_BER:
  2616			if (fe->ops.read_ber) {
  2617				if (fepriv->thread)
  2618					err = fe->ops.read_ber(fe, parg);
  2619				else
  2620					err = -EAGAIN;
  2621			}
  2622			break;
  2623	
  2624		case FE_READ_SIGNAL_STRENGTH:
  2625			if (fe->ops.read_signal_strength) {
  2626				if (fepriv->thread)
  2627					err = fe->ops.read_signal_strength(fe, parg);
  2628				else
  2629					err = -EAGAIN;
  2630			}
  2631			break;
  2632	
  2633		case FE_READ_SNR:
  2634			if (fe->ops.read_snr) {
  2635				if (fepriv->thread)
  2636					err = fe->ops.read_snr(fe, parg);
  2637				else
  2638					err = -EAGAIN;
  2639			}
  2640			break;
  2641	
  2642		case FE_READ_UNCORRECTED_BLOCKS:
  2643			if (fe->ops.read_ucblocks) {
  2644				if (fepriv->thread)
  2645					err = fe->ops.read_ucblocks(fe, parg);
  2646				else
  2647					err = -EAGAIN;
  2648			}
  2649			break;
  2650	
  2651		/* DEPRECATED DVBv3 ioctls */
  2652	
  2653		case FE_SET_FRONTEND:
  2654			err = dvbv3_set_delivery_system(fe);
  2655			if (err)
  2656				break;
  2657	
  2658			err = dtv_property_cache_sync(fe, c, parg);
  2659			if (err)
  2660				break;
  2661			err = dtv_set_frontend(fe);
  2662			break;
  2663		case FE_GET_EVENT:
  2664			err = dvb_frontend_get_event(fe, parg, file->f_flags);
  2665			break;
  2666	
  2667		case FE_GET_FRONTEND: {
  2668			struct dtv_frontend_properties getp = fe->dtv_property_cache;
  2669	
  2670			/*
  2671			 * Let's use our own copy of property cache, in order to
  2672			 * avoid mangling with DTV zigzag logic, as drivers might
  2673			 * return crap, if they don't check if the data is available
  2674			 * before updating the properties cache.
  2675			 */
  2676			err = dtv_get_frontend(fe, &getp, parg);
  2677			break;
  2678		}
  2679	
  2680		default:
  2681			return -ENOTSUPP;
  2682		} /* switch */
  2683	
  2684		return err;
  2685	}
  2686	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux